CHARLOTTE, N.C. ( TheStreet) -- Bank of America ( BAC) said early Monday that it has taken a $2 billion goodwill impairment charge and set aside a $3 billion provision as part of its fourth quarter earnings results as result of a settlement with Freddie Mac ( FMCC.OB) and Fannie Mae ( FNMA.OB) over repurchase claims on former Countrywide loans. Bank of America said the charges, to be taken as part of its fourth-quarter earnings, is the result of an agreement made with the two government-sponsored enterprises to resolve repurchase claims involving residential mortgage loans sold to them by entities related to Countrywide, which the Charlotte-based financial institution bought in 2008. Bank of America will take a $3 billion loan loss provision related to repurchase obligations for residential mortgage loans sold by the bank's affiliates directly to Freddie Mac and Fannie Mae, it said. Bank of America will also record a non-cash, non-tax deductible goodwill impairment charge of approximately $2 billion in the fourth quarter of 2010 in its Home Loans and Insurance business segment, it said. The provision results from both the GSE agreements and adjustments to the representations and warranties liability for other loans sold directly to the GSEs and not covered by these agreements, the bank said. The loans not covered by the agreements include both legacy Countrywide loans and loans originated on other legacy platforms. Through this provision, Bank of America said it believes that it has addressed its remaining exposure to repurchase obligations for residential mortgage loans sold directly to the GSEs. "These actions resolve substantial legacy issues in the best interest of our shareholders," Bank of America CEO Brian Moynihan said in a statement. "Our goals remain the same: put these issues behind us; focus on serving customers and clients; and continue to help distressed homeowners facing difficult times." The agreement with Freddie Mac apparently "extinguishes all outstanding and potential mortgage repurchase and make-whole claims arising out of any alleged breaches of selling representations and warranties related to loans sold by legacy Countrywide" to the agency through 2008. Those loans total 787,000 with an unpaid principal balance of $127 billion.