Bonds: Margin Buying and Repurchase Agreements

Can someone explain these two topics? I don’t follow the explanation in the Schweser book. Thanks.

1.Margin buying is like buying stock through margin account. use the bought bond as collateral for the loan, borrower may sale the loan to anyone in market. 2.Repo acctually is also loan, normally short term, few days; and lender agreed that must sale the collateral bond back to borrower at certain price at the end of term, the sale back price higher than original buy price, the price difference is the interest to lender. there are more details in CFAi books,although they have lots of erros at other session.