Lenders will often restructure a loan rather than foreclose on a property because it is less value-destroying. A loan modification primarily entails a change in the loan rate, principal balance and/or remaining time to maturity. We analyze optimal loan modification schemes in a stochastic home price and stochastic interest-rate environment. Lenders maximize their loan values by managing the value of the borrower's option to default on the loan and prepayment option. We argue that, controlling for the borrower's ability to pay, loan modifications via rate reductions and maturity extensions are ineffective, leading to dissipation in loan value to the lender, and resulting in a high probability of re-default by homeowners even after modification of their loans. In contrast, loan write-downs (the Principal Principle), not a favored recipe, and sometimes prohibited by covenants, are value-maximizing for the lender. A useful structuring device, the shared appreciation mortgage, enhances the ability to pay, mitigates adverse selection, and reduces the present value of expected deadweight foreclosure costs.