(a) Order of Withdrawals.—A qualified withdrawal from a capital construction fund shall be treated as made—
(d) Withdrawals To Pay Principal.—
If a portion of a qualified withdrawal to pay the principal on indebtedness is made from the ordinary income account or the capital gain account, an amount equal to the total reduction that would be required by subsections (b) and (c) if the withdrawal were a qualified withdrawal for a purpose described in those subsections shall be applied, in the order provided in joint regulations, to reduce the basis of vessels, barges, and containers owned by the person maintaining the fund. The remaining amount of the withdrawal shall be treated as a nonqualified withdrawal.
(e) Gain on Property With Reduced Basis.—
If property, the basis of which was reduced under subsection (b), (c), or (d), is disposed of, any gain realized on the disposition, to the extent it does not exceed the total reduction in the basis of the property under those subsections, shall be treated as an amount referred to in section 53511(c)(1) of this title withdrawn on the date of disposition of the property. Subject to conditions prescribed in joint regulations, this subsection does not apply to a disposition if there is a redeposit, in an amount determined under joint regulations, that restores the fund as far as practicable to the position it was in before the withdrawal.