(CNN) The gunman who authorities say killed nine coworkers in San Jose, California, had three pistols and 32 magazines on him and a stockpile of ammunition and guns at home, according to the Santa Clara Sheriff's Office.
They believe the shooting spree at the Valley Transportation Authority (VTA) could have been worse, but the gunman, identified as employee Sam Cassidy, apparently killed himself as deputies arrived on the scene.
"It is clear that this was a planned event and the suspect was prepared to use his firearms to take as many lives as he possibly could had Sheriff's deputies not made entry to stop his rampage," the Sheriff's Office said.
Authorities have yet to establish a motive for the shooting, but notes found in 2016, court documents and interviews with those who knew the gunman describe a man with anger issues dating back at least a decade.
Here is what we know about him:
Cassidy had worked at the VTA since January 2001. His most recent job was a substation maintainer, which the VTA said is someone who works on the equipment that converts the power to run light rail trains.
The shooting took place at about 6:30 a.m. PT at a light rail yard in San Jose as employees were starting trains up for the day, authorities said. Video shows that the gunman arrived about 5:30 a.m., FBI Special Agent in Charge Craig Fair said.
Law enforcement officers quickly arrived at the scene but did not exchange gunfire with Cassidy.
"I know for sure that when the suspect knew the law enforcement was there, he took his own life. Our deputies were right there at that time," said Santa Clara County Sheriff Laurie Smith.
The sheriff's office said in a news release Thursday that recently discovered evidence pointed to Cassidy as being angry about work.
"We can say that the suspect has been a highly disgruntled VTA employee for many years, which may have contributed to why he targeted VTA employees," the statement says.
The gunman fired 39 bullets and investigators think he targeted his victims, the sheriff told CNN.
During his rampage, the shooter told a local union official who was present but did not work for the VTA, "I'm not going to shoot you," according to Smith.
Cassidy had a hatred for his workplace that he expressed in notes discovered when his bags were searched almost five years ago, a Department of Homeland Security official told CNN on Thursday.
Cassidy was taken into secondary inspection after returning from a trip to the Philippines on August 8, 2016, and US Customs and Border Protection officers searched his belongings, the official said.
In addition to a black memo book filled with notes about hatred towards the transit agency, officers also found books about terrorism and fear and manifestos, the official said.
The Wall Street Journal first reported the CBP's search of Cassidy's belongings.
Cassidy was detained by CBP officials, at least in part because of red flags regarding sex tourism in that part of the world, the DHS official said. There is no indication that anything related to sex tourism was found.
It doesn't appear that follow-up action was taken after the 2016 search, the official said.
Cassidy traveled at least one more time to the Philippines after the 2016 inspection, the official said, but it's unclear if he was extensively searched after that subsequent trip.
San Jose officials said police were never informed of the stop or the writings.
Cassidy had three 9 mm pistols and 32 high-capacity magazines, the sheriff's office said Thursday. The magazines, which hold more than 10 rounds, are illegal to possess in California.
The three guns were legally obtained and registered, Fair told CNN.
Fair said he believes the three handguns were used during the attack, noting at one point during the shooting spree one of the pistols jammed.
The gunman had 11 magazines on his belt when officers located his body, Fair said.
During a sweep of the shooting scene, bomb-sniffing dogs alerted to the suspect's locker and found "precursor things for explosives," Sheriff Smith said.
She said the precursor devices included detonation pulls.
When authorities search the gunman's fire-damaged home they found 12 more guns and 22,000 rounds of ammunition. They also discovered suspected Molotov cocktails and cans of gasoline.
Investigators think the gunman set a fire at his house to coincide with the shooting, the sheriff's office said.
Cassidy is thought to have ignited a fire by placing ammunition inside a pot on the stove, surrounding it with accelerants and turning on the stove, according to Deputy Cian Jackson of the sheriff's office.
Surveillance video obtained by CNN shows a man identified as Cassidy leaving his home on Wednesday morning with a duffel bag. A neighbor, who did not want to be named, said the video was recorded around 5:40 a.m. and showed Cassidy leaving the house in a truck. The neighbor described Cassidy as a "quiet" and "strange" man.
The San Jose Fire Department said firefighters responded at a home in the 1100 block of Angmar Court at 6:36 a.m. local time, just minutes after law enforcement was called about the VTA shooting about 8 miles away.
It took firefighters about an hour to extinguish the two-alarm fire, which caused heavy damage and left the structure uninhabitable, the fire department said.
As of Friday the structure had been rendered safe and no longer posed a threat to nearby residents, San Jose Fire Department spokeswoman Erica Ray said.
Cassidy had a strained relationship with an ex-girlfriend, court documents show, which revealed troubling allegations she made in a filing in 2009 as she responded to a restraining order he filed against her.
The woman says she dated Cassidy for approximately one year in what she said became an off-and-on-again relationship after about six months.
She described Cassidy as having mood swings that were "exacerbated when (Cassidy) consumed large quantities of alcohol," she said in the court document, and she alleged he had bipolar disorder.
She said he enjoyed playing mind games with her, according to the court document.
"Several times during the relationship he became intoxicated, enraged and forced himself on me sexually," said the former girlfriend, who CNN is not naming and is reaching out to for comment.
Cassidy's ex-wife, Cecilia Nelms, told CNN affiliate the Bay Area News Group he resented his work. Nelms was married to Cassidy for about 10 years until the couple filed for divorce in 2005. She has not been in touch with her ex-husband for about 13 years, according to the outlet.
"He had two sides," Nelms said. "When he was in a good mood he was a great guy. When he was mad, he was mad."
He often spoke angrily about his coworkers and bosses, and at times directed his anger at her, Nelms told the outlet.
When the two were married, he "resented what he saw as unfair work assignments" and "would rant about his job when he got home," she said.
"He just thought that some people got more easy-going things at work, and he'd get the harder jobs," she said.