Peabody Energy Corp, the largest U.S. coal producer, reached a deal to cover mine clean-up liabilities while in bankruptcy with three U.S. states, court documents showed on Tuesday.

Peabody has benefited from a federal program known as self-bonding that allows the largest miners to extract coal without setting aside cash or collateral to ensure the company will restore the site to its natural setting.

The practice has come under scrutiny following bankruptcy filings by Peabody and other large coal miners because without collateral set aside for mine reclamation, taxpayers are potentially exposed to billions of dollars in cleanup costs.

Under agreements reached with Wyoming, New Mexico and Indiana, about 15 percent of Peabody’s $1.2 billion in self-bonds will be secured by debtor-in-possession financing during its bankruptcy.

Wyoming can receive $127 million cash if Peabody were to walk away from reclamation in that state while in bankruptcy, New Mexico $32 million and Indiana $17 million.

The agreements are similar to bankruptcy deals reached by coal miners Arch Coal and Alpha Natural Resources in Wyoming and West Virginia.

Peabody’s agreement must be approved by a federal bankruptcy judge at a hearing in August.

The deals did not specify whether Peabody must replace its self-bonds once it emerges from bankruptcy, as Alpha did this month in Wyoming.

In court filings, Peabody said that were it required to replace its self-bonded liabilities, its entire liquidity would be depleted, leaving it without enough cash to run its business.

This is a scenario regulators have said they want to avoid. If a producer walks away from its self-bonded mines, the state would be stuck with the cleanup.

There were $3.9 billion of self-bonds across the United States as of June 1, including $2.2 billion in the hands of bankrupt coal miners, according to federal mining regulator Office of Surface Mining and Reclamation Enforcement (OSMRE).

If Peabody were to handle its own cleanups, it said the bill would be significantly less than its $1.2 billion in self-bonds. Reclamation costs are listed on its books at $450 million, it said.

Peabody has already been taking steps to reduce its environmental liabilities in Wyoming by speeding up grass planting and regulatory paperwork at former mines.

The company also has self-bonds in Illinois, which has expressed concern over the company’s reclamation liabilities and was not included in the settlements.