By now, much of the excitement over Bank of America Corp.'s (BAC 0.83%) huge $16.65 billion settlement with the U.S. Department of Justice has died down, as investors and analysts alike hunker down to witness the bank's revival, now that the last of the big mortgage-related legal battles is over.

Though the accord is the priciest yet among the myriad big-bank settlements, the deal has produced some clear winners. Here are four groups that made out especially well – including some you've probably never heard of before.

Bank of America
There's little doubt that the big bank came out smelling like a rose on this one, despite the enormous size of the penalty. Analysts praised the removal of the last of the bank's "overhang" of legal problems regarding bad mortgage loans, and opined that CEO Brian Moynihan can now move forward with his plan to revitalize the bank.

The celebratory feeling emanates almost completely from the belief that this is the last shoddy-mortgage claim for which B of A will have to pay up. Time will tell, of course, whether or not that prediction pans out. Meantime, investors felt confident enough to bid up the bank's share price over $16.00 – a value not seen since April.

As for the amount of the settlement, Bank of America's bottom line won't be pinched as much as you might think. Not only will the bank be able to take sizable tax write-offs, but some of the $7 billion earmarked for homeowner relief will actually come from sources other than B of A.

How? In part because many of those mortgages are now being serviced by companies other than Bank of America, which means that those companies will now be responsible for assisting the borrowers of those troubled loans.

Bank of America shareholders
While the payout will reduce profits for another quarter, the bank's investors received the news cheerfully. Stockholders were recently rewarded for their patience with B of A when the bank raised its dividend from $0.01 to $0.05 per share. This was the first time since the financial crisis that the bank was allowed to do so, and the combination of a stronger balance sheet and no legal troubles on the horizon can only presage good things for B of A's long-suffering shareholders.

Pension funds
Public pension funds that purchased securities containing smoldering MBSes will also get a piece of the settlement pie. Nearly $1 billion of the penalty Bank of America will pay will be disbursed to states like California and New York, where the money will be allocated by those states' attorneys general to various public retirement funds.

Advocacy groups
As part of the consumer aid portion of the accord, B of A will get credit for making loans to low to moderate income borrowers, as well as cleaning up neighborhoods where neglected properties mired in the foreclosure process have blighted the surrounding area. Donations to non-profits that assist in these activities will be credited toward the required amount of relief contained in the settlement.

Two groups in particular that are likely to reap a windfall are NeighborWorks America, an affordable housing advocacy group, and the Interest on Lawyers' Trust Account organization, a legal-aid group for low-income persons. While NeighborWorks may only receive funds if B of A doesn't satisfy its contractual obligations regarding consumer relief by August 2018, IOLTA, which has offices across the U.S., and other legal-aid organizations, are scheduled to receive at least $30 million from the bank, with each jurisdiction to get at least $200,000. 

B of A has four years in which to implement the consumer relief portion of the pact. In many ways, the most expensive settlement in U.S. banking history just might turn out to be better than expected for Bank of America.