This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

SUTHERLAND SPRINGS, Texas — The gunman who carried out the massacre at a small-town Texas church briefly escaped from a mental health center in New Mexico in 2012 and got in trouble for bringing guns onto a military base and threatening his superiors there, police reports indicate.

Devin Patrick Kelley was also named as a suspect in a 2013 sexual assault in his Texas hometown of New Braunfels, about 35 miles (56 kilometers) from the scene of the church attack.

The records that emerged Tuesday add up to at least three missed opportunities that might have offered law enforcement a way to stop Kelley from having access to guns long before he slaughtered much of the congregation in the middle of a Sunday service. Authorities said the death toll of 26 included the unborn baby of one of the women killed. Kelley died of a self-inflicted gunshot wound after he was chased by bystanders and crashed his car.

The Air Force confirmed Tuesday that Kelley had been treated in the facility after he was placed under pretrial confinement stemming from a court-martial on charges that he assaulted his then-wife and hit her child hard enough to fracture the boy’s skull.

Involuntary commitment to a mental institution would have been grounds to deny him a weapon provided that records of his confinement were submitted to the federal database used to conduct background checks on people who try to purchase guns.

Kelley was also caught trying to bring guns onto Holloman Air Force Base in New Mexico when he was stationed there, according to an El Paso, Texas, police report released Tuesday.

While in the military, Kelley, who was 21 at the time, made death threats against superior officers, according to the June 2012 report, which also mentioned the military charges. He was eventually sentenced to 12 months of confinement for the assault.

The Air Force acknowledged Monday that it did not enter Kelley’s criminal history into the federal database as required by military rules, another way he could have been denied a weapon.

Had Kelley been convicted of sexual assault, he would likely have been prevented from purchasing a gun because federal guidelines prohibit sales to anyone convicted of a felony punishable by more than one year in prison. The Comal County sheriff said he was reviewing whether his department mishandled the sexual assault investigation.

Authorities recovered a Ruger AR-556 rifle at the church and two handguns from the shooter’s vehicle. All three weapons were purchased by Kelley, said Fred Milanowski, the agent in charge of the Bureau of Alcohol, Tobacco, Firearms and Explosives in Houston.

The El Paso report notes that Kelley was committed to a mental health facility in Santa Teresa, New Mexico, but at some point escaped and was later found by police at a bus station in downtown El Paso in June 2012.

Deputies were called to Kelley’s home in New Braunfels in June 2013 about the rape case and investigated for three months, Comal County Sheriff Mark Reynolds said. But it appeared that they stopped investigating after they believed Kelley left Texas and moved to Colorado. Reynolds said the case was then listed as inactive.

The sheriff said he was trying to determine how deputies came to believe Kelley had moved and why they did not continue to pursue the case, either in Colorado or after Kelley returned to the area later. Deputies were called to the same house in February 2014 to investigate a domestic violence report involving Kelley and Danielle Shields, his girlfriend at the time, whom he married two months later.

“The last information that we have is the suspect moved to Colorado and then the investigation seems to have tapered off,” Reynolds said Tuesday. “That’s what we’re looking into.”

The district attorney for Comal County said in an interview that she became aware of the sexual assault case Monday before the records were released to The Associated Press and other media.

“That case was never presented to our office,” Jennifer Tharp said.

The records from Comal County also describe a burglary that Kelley’s father, Michael, reported on his property the day after the sexual assault report. Michael Kelley told an officer that someone had taken a laptop computer and hard drive belonging to his son from a barn he had converted into an apartment for Devin Kelley. But Kelley said his son was unavailable to talk to police because he had been in a traffic accident that morning.

None of the documents explains whether there was a connection between the sexual assault report and the burglary report.

Meanwhile at the First Baptist Church in tiny Sutherland Springs, investigators continued analyzing a gruesome crime scene and tried to gain access to the shooter’s cellphone, a longstanding challenge for the FBI in thousands of other cases.

Authorities aimed to conclude the crime-scene investigation at the church by Wednesday evening. Investigators have no reason to believe anyone conspired with Kelley, who acted alone, said Texas Department of Public Safety Regional Director Freeman Martin.

Martin repeated earlier statements that the shooting appeared to stem from a domestic dispute involving Kelley and his mother-in-law, who sometimes attended services at the church but was not present on Sunday.

“We don’t know what he was thinking or what was in his mind,” Martin said. “There was conflict. He was upset with the mother-in-law.”

The gunman’s phone was flown to an FBI lab for analysis, but agents have yet to access it, said Christopher Combs, who is in charge of the agency’s San Antonio division.

The inability to access the shooter’s phone highlights a longstanding frustration of the FBI. Director Christopher Wray said last month that in the first 11 months of the fiscal year, agents were unable to access the content inside more than 6,900 mobile devices, an issue he said stymies investigations.

The FBI and other law enforcement officials have long complained about being unable to unlock and recover evidence from cellphones and other devices seized from suspects even if authorities have a warrant. Technology companies have refused to help, insisting they must protect customers’ digital privacy.

The long-simmering debate was on display in 2016, when the Justice Department tried to force Apple to unlock an encrypted cellphone used by a gunman in an attack in San Bernardino, California. The department eventually relented after the FBI said it paid an unidentified vendor who provided a tool to unlock the phone and no longer needed Apple’s assistance, avoiding a court showdown.