SAN JOSE, Calif. (KRON) – The gunman who killed nine people Wednesday at the San Jose, California rail yard where he worked has been identified as 57-year-old Sam Cassidy.

Cassidy arrived at the light rail facility for the Valley Transportation Authority in San Jose around 6 a.m. with a duffel bag filled with semi-automatic handguns and high-capacity magazines, Santa Clara County Sheriff Laurie Smith said.

“It appears to us at this point that he said to one of the people there: ‘I’m not going to shoot you,’” Smith said. “And then he shot other people. So I imagine there was some kind of thought on who he wanted to shoot.”

While there are no cameras inside the rail yard’s two buildings, Smith said footage captured him moving from one location to the next. It took deputies six minutes from the first 911 calls to find Cassidy on the third floor of one of the buildings, Smith said.

He killed himself as deputies closed in on the facility serving the county of more than 1 million people in the heart of Silicon Valley. More than 100 people were there at the time, and authorities found five victims in one building and two in another, Smith said.

Authorities do not yet know whether Cassidy had worked regularly with any of the victims. Investigators were serving search warrants for his home and cellphone, seeking to determine what prompted the bloodshed, the sheriff said.

Cassidy had worked for the Valley Transportation Authority since at least 2012, according to the public payroll and pension database known as Transparent California. His position from 2012 to 2014 was listed as a mechanic. After that, he was a substation maintainer, the records said.

His ex-wife, Cecilia Nelms, told The Associated Press that Cassidy had a bad temper and would tell her that he wanted to kill people at work, “but I never believed him, and it never happened. Until now.”

Nelms, teary-eyed and shaken by the news, said her ex-husband would come home wound up and angry about things that happened at work. As he talked about it, “he would get more mad,” she said. “He could dwell on things.”

When Cassidy lost his temper, Nelms said there were times she was scared. He was someone who could physically hurt others, she said.

Nelms said they were married for 10 years — Cassidy filed for divorce in 2005 — and had not been in contact for 13 years. She said he had been treated for depression.

Nexstar’s KRON4 spoke to Cassidy’s former girlfriend’s attorney, Robert Cummings, who said the two met on the dating site Match in 2009, and two months later he proposed. The girlfriend declined as she felt it was too fast.

Cummings said the girlfriend told him about Cassidy’s mood swings and was bipolar.

Doug Suh, who lives across the street from Cassidy, told local news outlets that Cassidy was “lonely” and “strange” and that he never saw anyone visit.

“I’d say hello, and he’d just look at me without saying anything,” Suh said. Once, Cassidy yelled at him to stay away as he was backing up his car. “After that, I never talked to him again.”

Court documents from 2009 reveal Cassidy filed a restraining order against an ex-girlfriend and another female roommate. In the documents the ex-girlfriend describes instances of sexual and physical abuse, heavy drinking and extreme mood swings due to his bipolar disorder.

The ex-girlfriend also said in documents that Cassidy would threaten to tell lies to her boss to complicate her career and would steal tools from his VTA coworkers.

Federal officials also revealed Thursday that when Cassidy was detained by U.S. customs officials in 2016 after a trip to the Philippines he spoke of hating his workplace.

Cassidy had a memo book that had notes on how he hated the Santa Clara Valley Transportation Authority. The memo also said he had books on terrorism but when he was asked whether he had issues with people at work he said no.

The Associated Press contributed to this report.