Fifteen more states reached an agreement with Purdue Pharma LP and members of its wealthy Sackler family owners that moved the OxyContin maker a step closer to resolving widespread opioid litigation and exiting bankruptcy protection.

All but a handful of states nationwide now support Purdue’s bankruptcy plan, with the latest agreement emerging after weeks of mediation.

The deal, outlined in bankruptcy court papers filed late on Wednesday, was reached after Sackler family members agreed to contribute another $50 million toward a proposed litigation settlement and to release tens of millions of additional internal documents for public inspection.

Another $175 million would come from relinquishing control of family charitable institutions. The Sackler family members have also agreed to a prohibition with regard to naming rights associated with charitable contributions until litigation settlement funds are fully paid, the documents said.

In all, the Sackler contributions toward Purdue’s bankruptcy-exit plan now total roughly $4.5 billion.

The plan aims to resolve some 3,000 lawsuits brought by U.S. communities alleging Purdue and its family owners contributed to an opioid crisis that has claimed the lives of roughly 500,000 people since 1999, according to the U.S. Centers for Disease Control and Prevention.

The Stamford, Connecticut-based company and family members have denied the allegations in the litigation.

Purdue said that the latest agreement built on support from other creditors in the company’s bankruptcy proceedings and that it hoped to reach additional consensus on its plan to move billions of dollars of value into trusts for addressing the U.S. opioid crisis. Sackler family members called the deal an “important step toward providing substantial resources for people and communities in need.”

The agreement, supported by longstanding holdouts including Massachusetts and New York, sets the stage for Purdue to gain court approval in coming weeks for its bankruptcy plan, which the company values at more than $10 billion. That value is contingent in part on future donations of overdose reversal and addiction treatment medications the company has under development.

The plan would dissolve the company and shift assets to trusts run on behalf of plaintiffs that alleged the company and its owners aggressively marketed the painkiller OxyContin while playing down its abuse and overdose risks.

“While I know this resolution does not bring back loved ones or undo the evil of what the Sacklers did, forcing them to turn over their secrets by providing all the documents, forcing them to repay billions, forcing the Sacklers out of the opioid business, and shutting down Purdue will help stop anything like this from ever happening again,” Massachusetts Attorney General Maura Healey, the first attorney general to sue Sackler family members, said in a statement.

If approved by the court, the bankruptcy plan would include legal releases shielding the Sacklers from future litigation. A bankruptcy judge halted lawsuits against both the company and the Sacklers after Purdue filed for Chapter 11 court protection in 2019.

“It is upsetting that the Sackler family never declared bankruptcy yet were still granted all the same protections of bankruptcy as their company,” New York Attorney General Letitia James said during a news conference with Healey and Minnesota Attorney General Keith Ellison on Thursday.

“There is no perfect solution here,” James added. “But we can’t let perfect be the enemy of the good. This deal gets one of the nation’s most harmful drug dealers out of the opioid business.”

Healey, who said she spoke to opioid victims earlier on Thursday, urged reform in aspects of the U.S. legal system that allowed the Sacklers to obtain relief from a federal bankruptcy court. But she welcomed the additional deposition transcripts, emails and other evidence that will eventually “be online forever, searchable and free to the public.”

Purdue in November separately pleaded guilty to three felonies arising from its marketing of prescription opioid painkillers, part of a separate settlement eclipsing $8 billion to resolve U.S. Justice Department criminal and civil investigations.

Sackler family members have not been criminally charged. They previously agreed to pay $225 million to resolve separate civil allegations with the Justice Department. The family members have denied those allegations.