In retrospect, the warning signs were there.
Before Devin Patrick Kelley carried out the deadliest mass shooting in Texas history on Sunday, the former airman:
• Was charged in military court with assaulting his then-wife and stepson, spent 12 months in a military prison and received a bad-conduct discharge;
• Was obsessed with a family dispute and sent threatening text messages to his mother-in-law, investigators said;
• Was charged with animal cruelty on suspicion of beating a dog;
• Posted pro-gun violence content and a picture of a rifle on his Facebook page, according to former classmates and community members.
As investigators piece together a portrait of the dead gunman, questions remain about what set him off and what possibly could have been done to prevent the massacre.
President Donald Trump called the mass shooting a "mental health problem at the highest level," not a "guns situation." Though Kelley's mental health history has not yet been disclosed, experts cautioned against focusing on that factor to the exclusion of others since a diagnosis of mental illness can't predict how a person will act.
According to psychiatrists and epidemiologists, "a history of violent behavior is a far better predictor of future violence than mental illness," Duke University professor Jeffrey Swanson said.
'Somebody really dropped the ball'
Kelley's record of domestic violence alone should have barred him under Texas law from purchasing the gun he used to kill 26 people at First Baptist Church in Sutherland Springs. His victims, ages 17 months to 77 years, include his wife's grandmother and the 14-year-old daughter of the church's pastor.
The Air Force acknowledged Monday it did not appropriately relay Kelley's court-martial conviction for domestic assault to civilian law enforcement, preventing the information from appearing in the federal database that licensed gun dealers are required to check before selling someone a firearm. "Had his information been in the database, it should have prevented gun sales to Kelley," the Air Force said in a statement.
The Air Force said the Air Force inspector general is conducting an investigation into what happened.
"Somebody really dropped the ball," former Air Force chief prosecutor Col. Don Christensen told CNN.
The shooter bought four weapons altogether -- two in Colorado and two in Texas, the Bureau of Alcohol, Tobacco, Firearms and Explosives said. They werepurchased from 2014 through this year.
Two handguns were found in the shooter's vehicle. A Ruger AR-556 rifle was found in front of the church where Kelley dropped it in a standoff with a local resident. Stephen Willeford, who lives near the church, shot Kelley twice before the gunman fled the scene in his car. Kelley, 26,was found dead in his car a few miles from the church. He had shot himself in the head.
Kelley bought the rifle in April 2016 from an Academy Sports + Outdoors store in San Antonio, a law enforcement official told CNN. When Kelley filled out the background check, he did not check the box indicating he had a disqualifying criminal history, the official said. He listed an address in Colorado Springs, Colorado, when he bought the rifle, the official said.
At one point, the shooter tried to get a license to carry a gun in Texas, but the state denied it, Texas Gov. Greg Abbott said, citing the director of the Texas Department of Public Safety. Buying a gun and obtaining a license to carry are two separate processes that don't rely on each other.
"So how was it that he was able to get a gun? By all the facts that we seem to know, he was not supposed to have access to a gun," Abbott told CNN. "So how did this happen?"
Details of domestic violence incidents revealed
Kelley served in logistics readiness at Holloman Air Force Base in New Mexico from 2010 until his discharge for assaulting his then-wife and stepson -- attacks that took place between 2011 and 2012.
Kelley initially faced multiple charges in his 2012 court-martial, according to records CNN reviewed. He was originally charged with assault and battery against his spouse, aggravated assault against his stepson and four charges involving firearms, including two of pointing a loaded firearm at his wife and two of pointing an unloaded firearm.
The firearms charges were dropped before trial as a result of an agreement in which Kelley pleaded guilty to the aggravated assault against the child and the assault against his wife.
As part of his plea, Kelley admitted to hitting his stepson on the head and body "with a force likely to produce death or grievous bodily harm." The injuries fractured the young boy's skull and caused internal bleeding, Christensen told CNN.
Kelley also admitted to hitting and kicking his wife repeatedly, choking her and pulling her hair.
The nature of crimes suggested a propensity for violence that should have been taken more seriously, Christensen told CNN.
Kelley, after serving 12 months in confinement, received a bad-conduct discharge in 2014.
KSAT-TV in San Antonio also reports that Kelley was reported missing from a mental health facility in New Mexico in 2012 and was eventually picked up by police. Read the incident report below.
Animal cruelty charge
That year, when Kelley was living in an RV park in Colorado Springs, a neighbor told police he saw him punch a dog.
Kelley initially denied the allegation but, according to court records, eventually pleaded guilty in October 2014 to an animal cruelty charge. He was ordered to pay more than $500 in fines and restitution, required to complete an animal cruelty evaluation and was given a deferred sentence of 18 months of unsupervised probation.
In March 2016, the guilty plea was withdrawn, and the case was dismissed after Kelley met the terms, the records show.
Neighbor heard target practice
Kelley was supposed to show up Sunday at his security guard job at the Summit Vacation Resort in New Braunfels, manager Claudia Varjabedian told CNN. His shift started at 4 p.m. No one had heard from him when they turned on the news.
"We couldn't get our mouths to close. We were all shocked," Varjabedian said.
He had only worked at the family resort for five weeks, she said, describing him as quiet. "He wasn't chatty with people, but he was polite."
He never let on to his plans, she said. On Friday, he asked for clarification on a policy related to vehicles on the property.
"He didn't seem like he had any plans to leave or do anything," she said. "I wish I could help by telling other people what to look out for to prevent this in the future."
In June, Kelley was registered as a noncommissioned security officer, affiliated with Schlitterbahn Waterpark and Resort in New Braunfels, where he lived, according to the state Department of Public Safety. In order to complete the registration, Kelley would have submitted fingerprints and fees.
Kelley worked at the waterpark for 5½ weeks this summer as a seasonal unarmed night security guard before he was terminated, Schlitterbahn representative Winter Prosapio told CNN. The park has not provided an explanation for why he was terminated.
Whether Kelley had any religious affiliation is unclear. The First Baptist Church of Kingsville, two hours south of Sutherland Springs, issued a statement saying that while Kelley was not a member of the church, he volunteered one night during the congregation's 2014 Vacation Bible School.
Kelley had been posting a lot about "non-God beliefs, atheism, a lot of gun violence and a lot of weapons that he was into," said Christopher Leo Longoria, who attended high school with him.
About a month ago, Longoria decided to unfriend Kelley because he didn't want to see the posts on his Facebook feed. He added that Kelley had also been launching personal attacks against friends. After learning of the church shooting, Longoria said: "I couldn't believe it, what a monster he turned into."
A screenshot of an October 29 Facebook post, ostensibly from Kelley, shows a picture of a rifle. In the status field above the picture is the message, "She's a bad bitch."
Kelley's Facebook page was taken down Sunday, hours after the shooting, but people in the Sutherland Springs area confirmed its existence and contents with CNN.
A gun expert told CNN that the weapon in the picture could be a Ruger AR-556, the type of gun used in Sunday's shooting. It is not clear whether the rifle in the picture was the gun from the massacre.
Kelley's social media posts suggested a fascination with mass shootings, according to a law enforcement official.
Robert Gonzalez, who lives near Kelley's residence in New Braunfels, about 35 miles north of Sutherland Springs, said he heard gunfire coming from Kelley's property every morning last week while he was working out on his porch.
"A load of rounds that would always be going off this time," he told CNN. "A .45 to an assault rifle, like a rapid fire all of a sudden. I was concerned because it was so close to our house."
It's not unusual for people in the area to practice firing on targets, said Gonzalez, who says he can identify guns by their sound because he was in the armed forces.
But he added it was an unusual amount of gunfire.