Over the past two years, controversial coal boss Don Blankenship has twice agreed to courtroom settlements requiring his company to clean up a checkered safety record, yet federal documents show Massey Energy mines continued to rack up serious violations in advance of the explosion that killed 29 miners this week.

The first legal agreement came when Massey Energy executives settled a lawsuit filed by corporate shareholders in May 2008, after the investors alleged that safety and environmental shortcuts at the mines were proving too costly in legal fees and fines. To settle the case, Massey agreed to form an independent safety committee, hire outside safety consultants, and enhance the safety procedures at its underground mines.

Joseph F. Rice, who represented the investors in the case, said he now wonders whether Massey complied with the court's order enforcing that agreement.

"We are in the process of determining whether they ignored that court order," Rice told ABC News on Friday. "We intend to find out what they've done. Our shareholders are concerned about what the company has or has not done after they made this agreement."

"The court has a lot of authority," Rice said. "If they did not comply with the order, the judge would have a lot of options open to him."

Six months after that case concluded, Massey subsidiary Aracoma Coal Co. pleaded guilty to "willful" safety violations in the 2006 mine fire that led to the suffocation deaths of two workers there.

"I want miners, who often work in potentially dangerous work environments, to be assured that my Office, MSHA, and other federal regulators are committed to vigorously enforcing Federal laws that protect the safety of miners in West Virginia," United States Attorney Charles T. Miller said at the time.

As part of the criminal plea in that case, the company began serving a three-year federal probation that included a promise to honor federal safety requirements, according to Hunter P. Smith, Jr., an assistant U.S. Attorney in the Southern West Virginia office. In an accompanying civil agreement, Aracoma also committed to reducing the number of infractions at the mine, noting that a record $4.2 million penalty would serve as a deterrent and "will encourage Aracoma's future compliance with the Mine Act and its mandatory standards."

Federal records show, however, that Aracoma was cited for safety infractions more than 300 times in the past year, including seven citations this past week – issued after the explosion at Massey's Upper Big Branch mine.

Safety problems have been even more serious at Upper Big Branch, the records indicate. Concerns about ventilation issues there had become so persistent that the morning before the deadly explosion, a top federal mine safety official, Kevin Stricklin, had flown into West Virginia in part to meet with Blankenship and discuss the concerns, ABC News has learned.

In a press release issued Friday, Massey said the company wanted to "reinforce its total commitment to safety."

"The safety of our members has been and will continue to be our top priority every day," the corporate statement said. "We do not condone any violation of Mine Safety and Health Administration regulations, and we strive to be in compliance with all regulations at all times."

The release says that its safety violations have occurred at a rate "consistent with national averages," though mining experts have disputed that, saying the mine was one of the region's more serious offenders. Davitt McAleer, a former top federal mine safety official, told ABC News that the number of violations raised "serious red flags."

In a statement that echoed the comments made by Massey CEO Blankenship, the company said it has invested heavily in keeping its miners safe. "Massey continues to invest in the development of safety innovations that exceed industry and regulatory standards," the company said. "Our lost-time incident rate has been better than the industry average for 17 of the past 19 years and has been improving significantly. These improvements have been achieved through concerted effort and significant investment."