Fixing bugs in the valuation of debt and equity