Bank of America (BAC) reported an $8.8 billion loss in the second quarter, or 90 cents per share, driven by the latest settlement with mortgage-backed securities investors. BofA settled representation and warranty claims from a group of RMBS investors led by Bank of New York Mellon (BK) in June for $8.5 billion. BofA assumed responsibility for the securities from Countrywide Financial Corp. when it bought the lender in 2008. The second quarter loss follows a $3.1 billion gain one year ago. "Obviously, the solid performance in our underlying businesses continues to be clouded by the costs we are absorbing from our legacy mortgage issues," said BofA CEO Brian Moynihan. In addition to the reps and warranty issues, BofA saw an $885 million reduction in its mortgage servicing rights as a result of higher servicing costs. In April, BofA signed a consent order with federal regulators, requiring a new servicing structure to provide borrowers with a single point of contact and other benefits. Another $716 million cost came from foreclosure delays the bank does not expect to recover and $1.9 billion in litigation expenses. The bank's real estate sector also saw a $604 million reduction in income, due to a decline in new mortgage originations, the bank said. Overall market demand, a drop in market share and its exit from the wholesale lending business all contributed to the decline. However, the production loss was offset by the $752 million gain from its sale of Balboa Insurance  Co. Nonperforming loans and foreclosed properties dropped to $30 billion from $35 billion one year ago, according to the bank. While improvements in most sectors allowed the bank to reduce its provision for credit losses to $3.3 billion, it had to add $412 million in loan reserves for real estate portfolios in previously acquired. "We intend to continue our efforts to put the mortgage uncertainty behind us, build capital through the strength of the franchise, and deliver the returns for shareholders that we owe them," Moynihan said. Write to Jon Prior. Follow him on Twitter @JonAPrior.