Nearly four years before Nikolas Cruz killed 17 students and educators at a Parkland, Fla., high school, he confided in a therapist he saw himself in a dream drenched in human blood.

A May 3, 2014, notation in a Broward County schools psychiatric file said Cruz "reported (a dream) last week of him killing people and covered in blood. He smiled and told the therapist that sometimes he says things for shock value."

After Cruz's disclosure to his therapist at the alternative Cross Creek School, administrators developed a "safety plan" to ensure the welfare of Cruz and others while he was on summer vacation. The plan included provisions for removing "all sharp objects from the home" and encouraging the youth to "verbalize what the problem is."

If talking about "the problem" was seen as a solution to Cruz's volatile behavior — and, in the short term, it might have been — it did not last. Portions of his psychiatric file, obtained by the Miami Herald on Friday, show a young man whose mental health exhibited frequent and extreme swings. His attitude would brighten for weeks at a time, and then descend again into paranoia and anger.

That pent-up rage exploded Feb. 14 when Cruz took an Uber car to his former high school in Parkland and walked onto campus carrying a bag with a semi-automatic rifle and magazines of ammunition. He went on a six-minute rampage, shooting into locked classrooms and through windows and walls and blasting people in the hallways. He killed 17 people, 14 of them students.

Then, wearing an old Marjory Stoneman Douglas High School Junior ROTC polo shirt, he fled the building with panic-stricken students and escaped the school before police entered. He was caught soon after.

Cruz was charged last week with 17 counts of premeditated murder and 17 counts of attempted murder. He already has confessed to police and this week withdrew a not-guilty plea. His attorneys at the Broward County Public Defender's Office hope to negotiate for a plea of guilty in exchange for a life sentence. Cruz, who was ordered held without bond Friday on the additional attempted murder counts, could face the death penalty.

The shooting in Parkland has set off a renewed gun control movement and led students at the school to call for a nationwide protest March 24 to call for stronger gun measures. In Florida, Gov. Rick Scott signed legislation Friday restricting some access to rifles and allowing police to strip people with mental illness of the right to own a gun. Nationally, members of Congress have filed gun legislation.

The rage and obsession with violence documented by Cruz's therapists during nearly two years of interactions when he was 15 to 17 years old continued through his school career. Again and again, authorities were warned about his explosive tendencies and lack of impulse control. Again and again, authorities ignored the warnings.

In addition to the troubling behavior Cruz exhibited at the schools he attended — including an incident in which he reportedly brought a backpack with bullets to class — law enforcement officers were also alerted that Cruz might be dangerous.

The FBI did not act on two tips about Cruz, one of which involved Cruz posting online that he planned to become a "professional school shooter." The Broward County Sheriff's Office also was warned about Cruz, and had received a report he "planned to shoot up the school."

Cruz alternated between periods of good behavior and periods of paranoia during which he acted out at school and at home, making fun of his peers, cursing at school staff and making threats, according to notes from his time at Cross Creek. The records obtained by the Herald documented weekly therapy sessions from February 2014 to December 2015.

In one session, Cruz acknowledged to his therapist he watched YouTube to "research wars, military material and terrorist topics." He said he wore military clothing. His mother, Lynda Cruz, who has since died, told Cruz's therapist his obsession with the military resulted from his "excessive gaming."

School administrators spoke with Lynda Cruz in the months that followed about their mutual concerns about Cruz's desire to own a gun and take shooting lessons. The therapist, a Sept. 23, 2014, notation said, "shared concerns with parent about his obsession with guns/military and his poor anger control." The note also cited concerns over the possibility Cruz would "deploy aggressive behaviors at home."

At the time, Lynda Cruz was considering buying her son a pellet gun for his birthday. A different therapist who appears to have visited the family at their home suggested the mother develop a "plan" in which the youth would be allowed to buy a gun if he was able to "earn it" with good behavior. There was "a plan in place at home in order to control his use of the pellet gun."

Cruz's school therapist, however, expressed reservations. "Parent was advised against getting him a gun (pellet) or classes for his birthday," the September notation said. "Parent advised to restrict access to any weapon."

The therapy files also show Cruz's strong desire to be sent to a regular high school. He frequently discussed transferring with his therapist but also expressed anxiety about being mainstreamed.

In some sessions, the therapist described Cruz as "receptive" or noted he'd had "positive" behavior at school. The therapist role-played with Cruz to teach him how to interact with his peers and avoid conflict. But after other sessions, the therapist noted troubling behavior at school and at home.

In one April 2014 session, the therapist discussed Cruz's "aggressive behavior at home due to his not getting his way." Cruz responded by saying he saw the therapist as a threat. The therapist noted Cruz was "very paranoid."

The next month, Cruz cursed at school staff and made comments to his teacher that made the school "fear that he may act out and harm others," the therapist noted. Cruz told the therapist he liked to make his teacher feel uncomfortable. A meeting was scheduled to discuss a treatment plan "to keep client and others safe," the therapist wrote.

Around this time, the therapist explained to Cruz he wasn't ready to attend a regular high school.

Cruz also fantasized about a "perfect summer" that revolved around guns and shooting, according to a short paper he wrote.

Under the heading "What my perfect summer would be," Cruz wrote about "buying some type of gun and shooting at targets that I set up with large amounts of ammo just for fun for hours," stopping only when he got bored or ran out of ammunition. Cruz said he also wanted to get a job and make money "so I can get things that I want for myself (instead) of come to this time wasting school that support stuped [sic] selfish children that I don't care about and gets in the way of my chances of leaving this place."

Cruz also wrote about his loneliness. "I will never be happy with my life I have no money or friends (sic)," he wrote. He complained about his "annoying mother who won't leave me alone."

In preparation for a summer 2014 recess, Cruz's school therapist and psychiatrist jointly wrote a letter to another one of the his psychiatrists articulating serious concerns. "At home, he continues to be aggressive and destructive with minimal provocation," the letter said. "For instance, he destroyed his television after losing a video game that he was playing. Nikolas has a hatchet that he uses to chop up a dead tree in his backyard. Mom has not been able to locate that hatchet as of lately."

"When upset he punches holes in the walls and has used sharp tools to cut up the upholstery on the furniture and carve holes in the walls of the bathroom," the letter added.

By the next April, though, after Cruz had shown "tremendous progress" in his behavior, Cross Creek began efforts to move him to a traditional school.

Psychiatric notes from that period describe a significantly less erratic youth. His mother reported he was making friends and had exhibited no signs of inappropriate behavior "in the community. She is happy that he has been doing better," an April 28, 2015, notation said.

Cruz had been able to "control" his behavior, both in school and at home, the April 28, 2015, notation said. He was noticeably less aggressive. Teachers did not report having to place him in "time outs."

"Parent has requested student to be mainstreamed," the report said.

In discussions about Cruz's desire to attend a "regular" school, psychiatric progress notes said he was encouraged to continue mental health medication, therapy and social work case-management at home, and was discouraged from becoming a cadet: "Interested in ROTC?" the report said. "Not advised."

Cruz started attending Stoneman Douglas part-time by October 2015. Later that fall, the therapist noted Cruz was going to be mainstreamed full-time beginning in January. At the last documented session, in December 2015, Cruz told his therapist he felt he would do very well at his new school