New York state has agreed to end its “overreliance” on solitary confinement as a means to discipline inmates in its prison system, the New York Civil Liberties Union said on Wednesday, limiting a practice decried by rights activists as inhumane.

The reforms, which the state agreed to implement within three years, were part of a settlement to a lawsuit brought against the state by the civil rights organization.

“Today marks the end of the era where incarcerated New Yorkers are simply thrown into the box to be forgotten under torturous conditions as a punishment of first resort,” NYCLU Executive Director Donna Lieberman said in a statement.

The state will commit $62 million on the reforms, which will include converting solitary confinement units into spaces with group learning rooms and outdoor spaces.

“This package of reforms will result in a safer correctional system, as well as a fairer and more humane response for inmates who engage in misconduct,” Governor Andrew Cuomo said in a statement.

Under the agreement, the state would move more than 1,100 people, about a quarter of its prison population currently confined to solitary spaces, into less secluded units.

The state also agreed to restrict the circumstances under which prisons impose solitary and the length of sentences involving isolation. It would eliminate nearly half of the 87 rule violations, including drug use and possession, punishable by the practice for one-time offenders.

A maximum three-month solitary sentence will apply to all but a few first-time rule violations, such as escape attempts and assault.

The agreement also requires more privileges to inmates in solitary, including access to reading materials and telephone calls. It bars the use of serving “inedible food,” including a block of dense mixed vegetables, meats and nuts and other ingredients, known in prison parlance as the “loaf.”

Additionally, more than 20,000 corrections officers will receive training aimed at diffusing and preventing incidents that might land an inmate in solitary confinement.

“Solitary confinement is mental torture that I wouldn’t want anyone to experience,” lead plaintiff Leroy Peoples, a former inmate who served more than two years in isolation, said in a statement. “A major milestone has been accomplished today.”

The agreement, which is subject to court approval, follows similar measures, including a package of reforms in California.

The policy shift came less than two months after the U.S. Department of Justice said its investigators had found a pattern of abuse of 16- and 17-year-old inmates that breached their constitutional rights.