In my father’s case:
His original $2,000 contribution is distributed tax-free because he already paid the taxes on the $2,000.
$15,000 of the distribution was derived from untaxed earnings…
$10,000 was deemed tax-free due to the first-time homebuyers exception.
He had to include the remaining $5,000 as taxable income.
Does this help?