PENSACOLA, Fla. (AP) — The Florida jail crippled by an apparent gas explosion was the subject of a five-year investigation that uncovered a facility so “grossly” understaffed that posts went unmanned and cells were seldom searched. Violence was pervasive and inmates were segregated by race.

Investigators are now trying to figure out whether the blast was an accident or something that could have been prevented. Inmates have told family members, the news media and their attorneys they smelled gas ahead of the explosion, but the county said they had no record of those concerns.

Still, questions were being raised about a jail with a well-documented record of troubles. The conditions at the Escambia County Jail were outlined in a Justice Department report last year and led to the facility being treated like a hot potato among local officials.

In the midst of the turmoil — and during an unprecedented rainstorm this week — the jail’s basement was flooded with more than 2 feet of water. It was running on generator power and one inmate told The Associated Press that toilets were broken and prisoners were using plastic bags.

Then, the blast hit. Two prisoners died, nearly 200 inmates and guards were injured and the jail was all but destroyed in the explosion late Wednesday night. In the confusion and chaos, 600 inmates rushed out of the building and authorities lost track of three inmates, who were later accounted for.

Bruce Miller, the elected public defender for the 1st Judicial District that includes Escambia County, said Friday he has long been worried about conditions and understaffing at the jail and hoped the explosion provided another opportunity to review the facility.

“I’ve always had concerns about the jail,” Miller said.

A prison guard union representative said the past problems and the explosion may not have anything to do with each another. He said officers train for fires and other emergencies every quarter.

“Nobody went into the day thinking anything was going to happen. For them to have gotten those people out like they did, they followed their procedures to the button. It could have been so, so, so much worse,” said Alan Miller of the Northwest Florida chapter of the Police Benevolent Association.

The jail’s problems were highlighted a year ago in a Justice Department report to the county commission and Sheriff David Morgan, citing “obvious and known systemic deficiencies” that led to the violation of inmates’ constitutional rights.

“Escambia County Jail has ignored obvious and serious risks to prisoner safety by grossly understaffing its security complement and by failing to take reasonable steps to adequately monitor prisoner violence,” the report said.

Violence, inadequate medical and mental health care and staffing shortages were among the biggest worries. The report even cited a March 2011 study by the county that said “large insufficiencies in jail staffing … raise the likelihood that something serious that could happen that would overwhelm the jail’s ability to respond.”

The county took control of the jail from the sheriff in October after contentious debates over budget cuts. Despite the DOJ report, the county hasn’t hired any additional jail staff, although officials were working on what needs to be done for the jail to come into compliance.

The Justice Department didn’t return phone calls or email.

Not everyone was happy about the decision for the county to takeover. County Commission Board Chairman Lumon May said he voted against it. He said there were too many issued that needed to be addressed and it was better for the sheriff to oversee the jail.

“I thought it was too much of an undertaking for the county,” he said.

Randy Etheridge, a defense attorney who has clients in the jail, said the dispute involving who oversees the jail has been part of its problems. He said one of his clients was in a holding cell on the first floor when the building collapsed and had to be pulled out of the rubble. He said he doesn’t think she had adequate medical attention after the blast.

As for the cause, Kevin Richardson, an agent for the federal Bureau of Alcohol, Tobacco, Firearms and Explosives, said a national response team will sift through the rubble to find out where it started and why.

That team, along with the state Fire Marshal’s office, will determine whether it could have been prevented.

“We’re here to get to the bottom of this, but it’s going to take some time,” said Ashley Carr, spokeswoman for state fire marshal Jeff Atwater. “Was this a tragic accident, or was this the result of someone’s action or inaction, and if so, who?”