Warning: MAJOR Avengers: Infinity War spoilers ahead.

Avengers: Infinity War screenwriters Christopher Markus and Stephen McFeely faced a formidable task in assembling so many superheroes for a single film. At least they had practice, having penned 2016’s Captain America: Civil War, otherwise known as “Avengers 2.5.”

But getting to a finished script required many detours: The duo acknowledges that there were numerous drafts for Infinity War, with various character arcs, plot points, and settings evolving along the way.

During a visit to Yahoo Studios, Markus and McFeely discussed some of the biggest, most surprising changes, from their early versions to the final cut.

Perhaps the most noteworthy revelation: There was a long-awaited reunion between Tony Stark/Iron Man (Robert Downey Jr.) and Steve Rogers/Captain America (Chris Evans), following their breakup in Civil War. An initial draft had the founding Avengers meet in a boardroom early on, joining their fellow heroes.

“Our first sort of wonky draft [had] the idea that they had to get back in the same room together and deal with that,” McFeely said. “[But it] meant that you’re slowing down your Thanos [Infinity] Stones [quest] to deal with other threats from other movies. And that became, as much as we wanted to do, and as many times as we wrote those scenes, it became clear that this movie needed to be propulsive and be about Thanos and what he represented to the Avengers.”

Two of the other Avengers also swapped positions. “There was one [version] where Spider-Man did not go to space, and where Falcon went to space,” Markus revealed. In the final cut, Spider-Man (Tom Holland) takes off for the cosmos with his mentor Iron Man and Doctor Strange (Benedict Cumberbatch), while Falcon (Anthony Mackie) joins the fight alongside old buddy Cap, Black Panther (Chadwick Boseman), and company in Wakanda. “And it was fun, it was interesting, it’s always great to have those guys in various situations and there was a lot to do with them in both situations, but we weren’t getting as much emotion as we could if we brought them back to people who know them.”

Of course, Markus and McFeely can’t claim credit for a couple of the best moments in Infinity War. The writers confirmed that Holland ad-libbed his shattering death scene in the film’s final moments (and no, it wasn’t because the Avenger Most Likely to Spoil didn’t have a script).

Then there’s Dave Bautista, the giant of a man behind Drax, who is quickly emerging as one of the funniest Avengers/Guardians, thanks to laugh-landing lines like, “Why is Gamora?,” which perfectly breaks the tension during a heated standoff between Iron Man and Star-Lord (Chris Pratt) on Titan.

“The script only said, ‘Where is Gamora?’ ‘I’ll do you even better: Who is Gamora?’ And then one day Bautista just goes, ‘I’ll do you one better: Why is Gamora?’” Markus recalled. “It’s like, ‘OK, you’re very good at your job.’”

Avengers: Infinity War is now in theaters.

Watch Markus and McFeely reveal the surprising influence of Frasier on the film:

Read more on Yahoo Entertainment: