This paper explains the events leading to the credit crisis that began in 2007 and the products that were created from residential mortgages. It explains the multiple levels of securitization that were involved. It argues that the inappropriate incentives led to a short-term focus in the decision making of traders and a failure to evaluate the risks being taken. The products that were created lacked transparency, with the payouts from one product depending on the performance of many other products. Market participants relied on the AAA ratings assigned to products without evaluating the models used by rating agencies. The paper considers the steps that can be taken by financial institutions and their regulators to avoid similar crises in the future. It suggests that companies should be required to retain some of the risk in each instrument that is created when credit risk is transferred. The compensation plans within financial institutions should be changed so that they have a longer term focus. Collateralization through either clearinghouses or two-way collateralization agreements should become mandatory. Risk management should involve more managerial judgment and rely less on the mechanistic application of value-at-risk models.