In a spectacularly awful summer for movies, it’s astonishing that Hollywood was capable of creating anything truly entertaining or memorable. It’s perhaps even more astonishing that the best movie of the summer is also the 13th of a series. Yes, “Captain America: Civil War,” Marvel’s ending to their Captain America trilogy, a sub-franchise within their cinematic universe, is both a spectacular movie, and one of the only good ones this summer. For a franchise as massive as Marvel’s, it would be all too easy for them to be at the bottom of Hollywood’s food chain. Instead, they deliver spectacular action, emotional depth, and moral complexity, even if they prove unwilling to let the story be as dark and tragic as it should have been.

After a disastrous mission in Lagos leaves innocent civilians killed in the crossfire, U.S. Secretary of State Thaddeus Ross (William Hurt) decides to bring the Avengers under United Nations control. Their actions had been too destructive, both in terms of the number of civilians killed in their crossfire and damage to diplomatic relations between states, and so they must be brought under bureaucratic control. Meanwhile, Cap’s former-friend-turned-brainwashed-assassin Bucky Barnes (aka The Winter Soldier, played by Sebastian Stan), comes out of hiding and is suspected of assassinating King T’Chaka of the country of Wakanda. The combination of Ross’ decisions and Bucky’s return create a rift between the Avengers, with Steve Rogers (AKA Captain America, played by Chris Evans) and his team valuing freedom and viewing Bucky as innocent, and Tony Stark (AKA Iron Man, played by Robert Downey Jr.) valuing security and viewing Bucky as more enemy than friend. Meanwhile, the villainous Baron Zemo (Daniel Brül) works from the sidelines, plotting to destroy the Avengers altogether.

If all of this sounds like a messy and cheesy plot for a movie, that’s because, by and large, it is. But writers Christopher Markus and Stephen McFeely manage to somehow pull off a story that is both dense and accessible, silly and serious. It grounds the plot in its characters, which have already been well-established due to the fact that this is the 13th movie in the Marvel Cinematic Universe. Their story moves at a brisk pace, but always does a solid job of establishing the setting, characters, and conflict of each individual scene, as well as successfully fitting each of the characters into the plot as a whole. Markus and McFeely are able to quickly establish the personalities of the new characters introduced in this movie, namely Spider-Man (played by newcomer Tom Holland) and Black Panther (Chadwick Boseman). Their villain, Zemo, is one of the best that Marvel has produced, if only because he’s a change of pace from the stock-standard, “take over the world” clichéd villains on Marvel’s roster. Most notably, the film’s final plot twist is one of the best that a major blockbuster has produced in a long time: It’s entirely possible to predict it if you watch closely, but regardless of whether or not you can foresee it, the climactic twist is simply devastating.

The cast does a fantastic job of bringing the excellent script to life. Evans gives his best performance as Captain America yet, portraying a weary hero in a world that no longer stands for what he believes in, while also brimming with the charisma necessary for a blockbuster movie. Downey Jr. is similarly at his best, this time portraying Stark as a nervous wreck, desperate to make up for the horrible mistakes of his past. He’s haunted and desperate to do something about it. Newcomers Holland and Boseman are absolutely terrific, Holland for capturing the likability and awkwardness that Peter Parker requires, and Boseman for his stoicism and intrigue.

Of course, none of this would matter if the movie couldn’t deliver exciting action scenes. Luckily, directors Joe and Anthony Russo deliver breathtakingly intense and surprisingly creative action, from car chases with characters leaping in and out of vehicles, to more intimate, close-quarters battles between heroes. The highlight of the film, a fight between the two teams of heroes, set in an airport, combines humor, action, and surprising levels of creativity, as the directors manage to play the heroes’ individual powers off of each other (i.e. Spider-Man stealing Captain America’s shield with his web slingers; yes, I’m aware of how childish that sentence sounded). The Russo brothers’ direction is exciting, creative, and absolutely thrilling.

The conflict between Rogers and Stark is both deeply personal and symbolic of a larger moral debate: Is it better to be free to make your own decisions, even if this means you’ll likely choose to protect those close to you no matter the cost, or to surrender this freedom for the greater good? This philosophical battle between individual responsibility and utilitarianism is well developed, but unfortunately the movie errs in attempting to make Captain America ultimately look like the good guy. Captain America may have sound virtues, but his desire to protect Bucky at any cost has enormous consequences for his friends, something that the movie seems to brush over a little too easily. Furthermore, the movie is slightly unsure about what to do with Tony Stark. In attempting to make Captain America the true hero of the film (it is, to be fair, named after him), the movie makes Tony out to be a wannabe Machiavellian mastermind, someone attempting to manipulate his friends, rather than someone fighting for what’s right. Again, it’s Captain America’s movie, but the film as a whole would have been much better off had it had more moral ambiguity.

Then there’s the ending, which isn’t nearly as tragic as it needed to be (and, yes, mild spoilers ahead). For one, it’s completely ridiculous for a movie subtitled “Civil War” to end with all of its heroes alive. While War Machine (Don Cheadle) is paralyzed from the waist down, and Bucky loses his (metal) arm, a movie that promises a “civil war” needs to deliver all the tragedy that comes with one. Furthermore, the tone of the final scenes is wildly off. Rather than end on a note of tragedy and despair, the film suddenly swerves from its downbeat climax to a final note of optimism. Why would Steve Rogers trust Tony Stark enough to contact him? Why would Tony Stark seemingly ally himself with Steve Rogers over the Secretary of the United Nations, after all Rogers did to him? Naturally, the only rational reason is that Marvel wanted to sell their next movie, and the best way to do that is to end on a happy note rather than a sad one.

To be fair, the movie included a brief moment in which Zemo implies his plans to break up the Avengers have already succeeded, adding some level of darkness to the ending. However, the scene is far too brief, and not nearly memorable enough, for it to have any real impact.

Yet, in spite of its problems, “Captain America: Civil War” was still the best movie of the summer of 2016. While that alone may not mean much, it’s still a fantastic film, combining explosive entertainment, emotional depth, and some (admittedly flawed) food for thought.