When longtime fans think of Star Trek, they conjure up creator Gene Roddenberry’s original utopian vision: a collectivist, multicultural future where money is no longer needed, and characters are happy to go on exploratory five-year missions for no reason other than their own need to bring good into the world.

As audiences discovered this past weekend, it’s basically everything director Justin Lin destroys in the first 20 minutes of Star Trek Beyond.

But for a 50-year-old franchise that rebooted itself in 2009 with a more action-oriented, Star Wars-ian vibe, the chaos that kicks off Beyond was a necessary step. According to director Justin Lin, it allowed him and the screenwriting team of Simon Pegg and Doug Jung to bring the film series back to its television roots. By taking everything away from Kirk, Spock, Bones, and the rest of the crew, the filmmakers put the fate of the series’ basic worldview in the hands of its characters — either to prove that it still had relevance in 2016, or kill it off completely.

Warning: spoilers for Star Trek Beyond below.

"I had to really understand what we were going to do on a thematic level."

"I was going to go make something on my own when I got the call from J.J. [Abrams]," Lin tells me about his initial involvement with the project. Production was set to begin in just six months with no script in place, and while the opportunity to join such a huge franchise was tempting, he’d already spent plenty of time crafting his own blockbuster series with the Fast & Furious films. "Before I said yes, I had to really understand what we were going to do, even on a thematic level. I thought, okay, it’s going to be 50 years [since the show started]. It would be great if we can somehow come up with a journey for these characters to deconstruct Trek, to deconstruct a lot of the ideals of the Federation. By doing that, maybe by the end, we can reaffirm why there is so much passion and so much love for this franchise."

"It was like, 'Let’s ask some questions that haven’t been asked before,'" explains Pegg, particularly when it came to the universe’s United Federation of Planets — perhaps the biggest symbol of the show’s utopian ideals. "It felt good to question whether they weren’t just a version of the Borg in a way. Whether they were just a force of assimilation, not a force of collectivism and goodness."

For Lin, deconstructing Star Trek started with an idea that he admits was rather literal: taking the Enterprise apart piece by piece in one of the film’s opening set pieces. "Simon was like, 'You can’t destroy the Enterprise and you can’t do it in the end of the first act. It has to be the end of the movie!'" Lin laughs. "That was our first meeting. We walked out and I think all of us were like, 'I don’t want to work on this movie. What’s going on?'"

"We call it The Longest Day," Pegg smiles. "We were in this room at the SoHo Hotel, just talking for 16 hours and we didn’t seem to be getting anywhere. But it was a great way to establish that all of us really wanted to make the best film we could."

"This sort of rampant xenophobia seemed to be reestablishing itself."

But as the team started writing the script — Pegg was still shooting Mission: Impossible - Rogue Nation, so the trio would sometimes be working in different time zones as the calendar raced toward production — they found themselves looking to political events, where the first signs of the Brexit movement and the start of the US presidential race resonated with the story they wanted to tell. "It was all bubbling up then, with the Scottish referendum and various acts of separatism around the world," Pegg explains. "Trump talking about building a wall between here and Mexico. This sort of rampant xenophobia that seemed to be reestablishing itself."

In the finished film those concepts manifest in the form of Idris Elba’s Krall. A former soldier intent on stopping the Federation’s spread across the galaxy, Krall comes across ideologically as the anti-Roddenberry. He preaches isolationism where the Federation wants to expand and include all; he rejects peace and sees solutions only in military strength. It’s not subtle allegory, but it works, and as the crew of the Enterprise recover, they learn the only way they will be able to defeat Krall is to come together and work as a whole — a literal depiction of Roddenberry’s multicultural future.

"We liked the idea of old god versus new," says Pegg. "Of narrow-minded thinking, or fear of collectivism, versus the Federation model, which is to embrace and expand in a non-aggressive way. That seemed like the obvious thing to do for this 50th anniversary iteration of the story." It turns the film into a thematic proof, making the case for the original show’s vision over the course of its running time.

A soft reboot toward TV Trek

Star Trek Beyond is an entry in a successful series of blockbuster movies, so of course everything eventually resolves to allow sequels to keep coming down the line. (In fact, Paramount’s already green-lit the next installment.) But by creating a movie that feels more like an episode of the original show, with its five-year mission and themes intact, Lin and his writers have also performed a sort of soft reboot. And to Pegg, the closer it feels to the television series, the better.

"When we spoke about [writing Beyond], it was, 'Let’s make it as if an episode of the original series had been injected with gamma radiation,'" he says. "The crew happen upon a mysterious planet. They’re on the surface. They meet an adversary. They learn a lesson. It’s what the original series episodes were constituted by, but with the trappings of a gigantic, summer blockbuster. Which is what the movies always were, really."

"They had to be one-off events, celebrations of the TV show," Pegg says. "That’s why I’m so glad that Star Trek is back on television now, because that’s where it belongs. That’s its home."

How filmmakers manipulate emotions using color