In a contingent claims framework, with a single issue of debt and full information, we show that the presence of a bankruptcy code with automatic stay, absolute priority rules, and potential debt forgiveness, can lead to significant conflicts of interest between the borrowers and lenders. In the first-best outcome, the code can add significant value to both parties by way of higher debt capacity, lower spreads, and improvement in the overall value of the firm. If the control is given to borrowers about ex-ante timing of entering into bankruptcy and the ex-post decision to liquidate once the firm goes into bankruptcy, most of the benefits of the code are appropriated by the borrowers at the expense of the creditors. We show that the lenders can restore the first-best outcome, in large measure, by seizing this control or by ex-post transfer of control rights which allows them to decide when to liquidate the firm that has been taken to the chapter 11 process by the borrowers. Irrespective of who is in control, our model implies, based on the term structure of probabilities of default and liquidation, that firms are more likely to default on average and are less likely to liquidate on average relative to the benchmark model of Leland (1994).