In an agreement between Tredyffrin Township and Pennsylvania's Department of Environmental Protection, the township said it expects to replace a 36-year-old sewage pipeline that ruptured and has spilled millions of gallons of untreated sewage in the last few years into Valley Forge National Historical Park and Valley Creek, a tributary of the Schuylkill.

Tredyffrin and its municipal authority violated the state's Clean Streams Law in three sewage-line ruptures in March 2012 and February and March 2014, in which more than 18.3 million gallons of sewage spilled into Valley Creek, according to a Nov. 21 court order from Chester County Court.

Under the agreement, Tredyffrin must decide by early 2016 on a long-term plan to prevent ruptures. The plan will most likely involve replacing the pipeline. The township also has to pay a $110,500 penalty.

Tredyffrin notified the DEP after each rupture and knew enforcement actions would result, said Vincent Donohue, the township solicitor. After each of the three spills, Tredyffrin made adjustments to the sewer system, according to the court order.

Donohue said the township had been working on the actions mandated in last month's court order for about a year.

The township "wants to avoid another one of these incidents as much as anybody," he said.

Valley Creek is designated as an "exceptional value" stream, meaning the state considers its water to be of the highest quality. The Pennsylvania Fish and Boat Commission also has named Valley Creek as a "Class A wild trout stream."

Tredyffrin also must review its procedures and develop an emergency response plan in case the pipeline ruptures again. The township must submit the plan to the DEP by Jan. 20.

"We were pretty relieved," David Masur, director of PennEnvironment, said of the agreement. "We thought the timeline is aggressive yet doable." PennEnvironment is an environmental advocacy group that notified the township in September that it planned to sue to enforce the federal Clean Water Act.

The Valley Creek Trunk Sewer, which includes the pipeline, transports untreated sewage from Tredyffrin, Malvern Borough, and the townships of Easttown, East Whiteland, and Willistown to the Valley Forge Sewer Authority wastewater-treatment plant in Phoenixville.