FILE - In this May 1, 2014, file photo survey crews in boats look over tanker cars as workers remove damaged tanker cars along the tracks where several CSX tanker cars carrying crude oil derailed and caught fire along the James River near downtown Lynchburg, Va. Inspectors have found almost 24,000 safety defects over a two-year period along United States railroad routes used to ship volatile crude oil. Data obtained by The Associated Press shows many of the defects were similar to problems blamed in past derailments that caused massive fires or oil spills in Oregon, Virginia and Montana. (AP Photo/Steve Helber, File)

FILE - In this May 1, 2014, file photo survey crews in boats look over tanker cars as workers remove damaged tanker cars along the tracks where several CSX tanker cars carrying crude oil derailed and caught fire along the James River near downtown Lynchburg, Va. Inspectors have found almost 24,000 safety defects over a two-year period along United States railroad routes used to ship volatile crude oil. Data obtained by The Associated Press shows many of the defects were similar to problems blamed in past derailments that caused massive fires or oil spills in Oregon, Virginia and Montana. (AP Photo/Steve Helber, File)

BILLINGS, Mont. (AP) — When a freight train derailed in the Montana town of Culbertson, spilling 27,000 gallons of crude oil, investigators blamed the 2015 accident on defective or missing fasteners used to hold the tracks in place.

The previous year, cracks in a track that went unrepaired caused a train hauling oil to come off the rails and explode along the James River in Lynchburg, Virginia. Broken bolts were cited in another oil train derailment and fire last year in Mosier, Oregon.

Data obtained by The Associated Press shows that tens of thousands of similar safety defects were found when government inspectors checked the rail lines used to haul volatile crude oil across the country. The defects included rails that were worn, bolts that were broken or loose or missing, and steel bars that had cracks.

ADVERTISEMENT

Such flaws are not uncommon across the nation’s 140,000-mile freight rail network. But these nearly 24,000 imperfections drew heightened attention because of a surge in recent years of domestic energy production that has increased rail shipments of oil and the number of major derailments.

The inspectors also noted failures by railroads to quickly fix problems identified through inspections.

A former senior official at the Federal Railroad Administration said the findings reinforce the need for railroads to stay on top of regular maintenance.

“All of this is a call for continued vigilance,” said Steven Ditmeyer, who reviewed the inspection data and directed the railroad administration’s Office of Research and Development for eight years. “One defect or one violation of the right kind can cause a derailment.”

It can be difficult for railroads to know when a seemingly small problem will result in an accident, he said.

The statistics “give a good indication of the track quality,” Ditmeyer said, although most defects will not cause a derailment.

In all, nearly 24,000 defects were found on almost 58,000 miles of oil train routes in 44 states. The inspection program began two years ago following a string of oil train accidents across North America, including a 2013 derailment in Quebec that killed 47 people in the community of Lac-Megantic.

Federal regulators said the inspections resulted in 1,118 violation recommendations and prompted railroads to be more responsive to inspectors and to improve safety.

A violation recommendation occurs when an inspector finds something serious enough to warrant a potential penalty or a railroad fails to address a defect. Federal officials declined to say how many penalties had been issued under the crude-by-rail inspection program.

The rail industry views safety defects as warnings from regulators, said Jessica Kahanek, a spokeswoman for the Association of American Railroads.

Violations are a better indicator of safety problems because not all defects pose an immediate risk, she said, explaining that hundreds of the violation recommendations were “paperwork-related,” such as railroads not providing required forms to government inspectors.

Omaha, Nebraska-based Union Pacific received most of the violation recommendations issued under the targeted inspection program — more than 800. A breakdown for violations involving other railroads was not available.

Union Pacific agreed to increase its inspection frequencies following the Mosier derailment under an agreement with federal regulators who said the railroad’s inspection program was too lax.

Railroad spokeswoman Calli Hite said the railroad shares the railroad administration’s dedication to safety.

“Union Pacific has always paid close attention to track conditions and inspections,” Hite said.

Most violations were found in the months after the inspection program began in January 2015 in the Southwest, where officials said Union Pacific runs a majority of the oil trains. In many cases, violation recommendations came after the railroad did not respond quickly enough to problems found by inspectors, said Marc Willis, a spokesman for the railroad administration.

Subsequent inspections turned up thousands of additional safety problems but far fewer recommendations for violations.

That was because the high number of violation recommendations for Union Pacific sent a message to the entire industry to quickly address any issue raised by inspectors, officials said.

“Railroads are paying closer attention,” Willis said, adding that derailments have fallen 10 percent since the inspection program began. “Although many minor defects still are being identified ... both FRA and railroad inspectors are finding fewer serious conditions, resulting in significant safety improvements.”

It’s uncertain whether the targeted inspection program for oil trains will continue under President Donald Trump’s administration, he said.

Since 2006, the United States and Canada have seen at least 27 oil train accidents involving a fire, derailment or significant fuel spill. Besides the targeted inspection program, U.S. and Canadian officials have responded with more stringent construction standards for tens of thousands of tank cars that haul oil and other flammable liquids.

The amount of oil moving by rail peaked in 2014 then dropped after crude prices collapsed. Major railroads reported moving more than 43,000 carloads of crude in the fourth quarter of 2016, down almost 50 percent from a year earlier, according to the railroad association.

___

Follow Matthew Brown on Twitter at https://twitter.com/matthewbrownap .