Goldman Sachs has agreed to pay $5 billion to stave off prosecution for deceitfully packaging bad mortgages and selling them to investors for “tens of billions of dollars” leading up to the financial crisis.

The bank agreed to a set of facts [PDF] laid out by the Department of Justice which details how Goldman Sachs employees knew what they were doing was wrong and did it anyway. “If only they knew…….” Goldman’s head of due diligence wrote in one email, after an employee in a different department sent them a report praising the soundness of the loans.

Of the $5 billion, $670 million will go to New York State—$480 million in consumer relief and $190 million in cash. Goldman Sachs is the last major American bank to settle with the government over the subprime lending crisis.

The settlement does not include any criminal penalties; the words “illegal” or “wrongdoing” or “fired” or “terminated” are not included in the language. The New York Attorney General, “based on its investigation, believes that there is an evidentiary basis for potential legal claims by the NYAG against Goldman Sachs.” The bank agrees.

"We are pleased to put these legacy matters behind us,” Goldman Sachs wrote in a statement. “Since the financial crisis, we have taken significant steps to strengthen our culture, reinforce our commitment to our clients, and ensure our governance processes are robust."

In 2010, Goldman Sachs paid a $550 million settlement to the SEC to avoid prosecution for their role in profiting off of toxic mortgages, and in 2009 the bank paid $60 million more to Massachusetts.

In 2015, Goldman Sachs listed $86.73 billion in equity.