This week’s Disney-Fox merger is impactful for many reasons — chief among them, a pattern of major media acquisition continues unabated as macroeconomic factors tip the scales in favor of consolidation — but it also represents the biggest “undo” in Marvel Studios’ decadelong turnaround. While a hit Marvel film is now almost a foregone conclusion, there was a time when the company, fresh out of bankruptcy, sold the rights to nearly every character it had for what would now be considered laughably small sums. By the time it became a dominant production company in its own right, contracts across Hollywood vastly limited how much of its own back catalog it could use.

Since 1998, there have been over 50 films based on Marvel comic characters, from Blade (produced by New Line Cinema) through this month’s Captain Marvel. Only 21 of them have been considered canonical to the Marvel Cinematic Universe (MCU), with all but six exclusively produced and distributed by Marvel Studios. The others were produced and/or distributed by almost every major film company out there: Paramount, Universal, New Line, Warner Bros., Columbia/Sony Pictures, Lionsgate, and 20th Century Fox — the latter of which produced 16 Marvel IP-based films, with two more due out by the end of this year.

But now, with over $18 billion in worldwide box office grosses for the MCU alone and a long history of contractual negotiations, acquisitions, and at least one sandwich thrown, Marvel has reclaimed the rights to nearly its entire cast of characters. Here’s how it got here, and what’s left to collect.

Assembling the first Avengers

When Marvel Entertainment Group established Marvel Films in 1993, the company’s goal wasn’t to make movies itself, but to license out virtually every character imaginable while maintaining some creative oversight. Even Iron Man during this span — the film that would kickstart the MCU in 2008 — was at times in development at Fox, Universal, and New Line before reverting to Marvel. In an alternate timeline, we got Tom Cruise as Tony Stark.

While the licensed franchises from the turn-of-the-millennium period — including Blade, X-Men, and Spider-Man — were box-office successes, Marvel saw very little of the grosses, and instead hoped to make its money off of ancillary businesses like toys and comics. (For example, while the first two Spider-Man films made over $1.6 billion at the worldwide box office, Marvel’s estimated revenue from them was just $62 million, less than 4 percent of the total.)

That all changed when David Maisel, who joined Marvel in 2003 as chief operating officer, convinced Marvel Studios founder Avi Arad and Marvel Comics CEO Ike Perlmutter to hit the brakes on licensing and set about to make their own films. (And not a moment too soon; in one of the many what-ifs of this period, Marvel was in the middle of negotiating licenses to give Captain America to Warner Bros. and Thor to Sony.) Maisel managed to raise $525 million — a majority from Merrill Lynch, with additional support from Paramount and Universal in exchange for distribution rights — to make 10 films, capped at a budget of $165 million each with a PG-13 requirement, based on what were then considered “second-tier superheroes, who may not resonate with younger moviegoers.”

Those first two films — 2008’s Iron Man and The Incredible Hulk — made over $848 million collectively, with Iron Man carrying most of the weight. From there, Marvel Studios, under the guidance of president Kevin Feige, who famously came up with that first post-credits scene between Tony Stark and Nick Fury, began its historical run and never went back to licensing out its characters. After Disney acquired Marvel Entertainment in 2009, it quickly moved distribution in-house (the first movie released by Disney would be Marvel’s The Avengers in 2012).

That also meant the studios that did have Marvel IP, many of whom were already seeing major commercial success, held onto those licenses pretty tightly — chief among them Sony and Fox.

Sony, Spider-Man, and a sandwich

Attempts to make a Spider-Man film date back to the 1980s, and include a wild and thorough “scriptment” — basically, a treatment with actual dialogue — from James Cameron (you can read it here, if you’d like). The years of development eventually led to a lengthy court battle between MGM and Sony, with the latter prevailing. In another what-if moment, according to the Wall Street Journal, Marvel offered Sony the rights to “nearly every Marvel character [not owned by Fox] — including Iron Man, Thor, Ant-Man, Black Panther and more — for $25 million” in 1999. Sony only bought the rights to Spider-Man and its related characters.

Born from the deal, Sam Raimi’s Spider-Man trilogy was a commercial smash, with the three films grossing nearly $2.5 billion worldwide. Raimi left the franchise before a fourth film could be made, which would’ve been the first one post-Iron Man, reportedly because he felt he couldn’t adhere to Sony’s proposed summer 2011 date and “keep the film’s creative integrity.”

That’s when Sony decided to reboot the series with director Marc Webb, and Andrew Garfield in the title role. Sony wanted the new Amazing Spider-Man franchise to kickstart a full cinematic universe à la the MCU, which would include a Sinister Six movie from The Martian writer Drew Goddard. But the poor reception to the sequel — a series box office low point — led Sony to shift gears (although Goddard recently told Polygon he hopes the Sinister Six movie could still happen).

Around this time, after flirting with the idea of Raimi returning to direct a Spider-related reboot, Sony and Marvel first discussed some kind of collaboration. Those initial talks didn’t go so well, with Sony executive Amy Pascal at one point throwing a sandwich at Kevin Feige. But in February 2015, the studios announced a deal that would bring Spider-Man into the MCU. Marvel won the rights to put Spidey, now played by Tom Holland, into team-up films like Captain America: Civil War and Avengers: Infinity War; Sony retained the right to produce MCU-approved solo films. The deal was very specific, with television rights — and by extension, Disney Plus streaming rights — reportedly still belonging to Sony.

(I’m pausing here to reemphasize: Oh, what a world we’d be in if this 57-page James Cameron Spider-Man scriptment you can read in its entirety had happened.)

Fox’s Marvel IP war chest

Marvel’s licensing bonanza put some of the company’s biggest properties in Fox’s stable: the X-Men, which it acquired by way of powerhouse producer Lauren Shuler Donner, who purchased the rights in 1994; and the Fantastic Four, for which it obtained the license by way of Constantin Film, which had itself acquired the license years prior and tried to hold onto it through some rather dubious means (including a never-intended-for-release movie made to extend the license).

The ‘Artisan MCU’ that almost was In yet another major what-if, Marvel entered a joint venture in 2000 with Artisan Entertainment to produce 15-plus films based on (among others) Deadpool, Captain America, Thor, Ant-Man, and Black Panther. While most of the characters (eventually) reverted to Marvel, Deadpool would be picked up by Fox just in time to be included in 2009’s abysmal Wolverine. At least it worked out in the end.

The first two Fantastic Four films were commercially successful, but critically panned. The silver lining was that the Human Torch, aka Chris Evans, was able to later take on the role of Steve Rogers in Captain America. The 2015 Fantastic Four did worse than its predecessors, with the Human Torch role again proving to be good luck for the MCU: Michael B. Jordan would later go on to play Killmonger in Black Panther. By the end of its 10-year run, the Fantastic Four franchise had grossed just shy of $788 million worldwide. That same year, Marvel Studios made nearly $2 billion across two films (Avengers: Age of Ultron and Ant-Man).

The X-Men franchise, though it certainly had its fair share of lows and soft reboots, fared much better overall. From a rights standpoint, Fox and Donner’s deal was a treasure trove, full of not just characters that were obvious X-Men, but virtually any mutant in Marvel Comics history. The terms were so inclusive that no character in the MCU has been able to utter the word “mutant.”

Though the exact contractual details have never been revealed, executives involved with the deal have hinted at interesting gray areas, in particular with the characters Scarlet Witch and Quicksilver. As Kevin Feige noted in 2012, “It’s a little complicated, but if [Fox wants] to use them in an X-Men movie, they could, and if we want to use them in an Avengers movie, we could.”

That is, in fact, exactly what happened, with Quicksilver appearing in both 2014’s X-Men: Days of Future Past and 2015’s Avengers: Age of Ultron. How? Well, in the comics, both heroes — twins — are the children of Magneto, making them mutants, which means Fox could claim usage rights. At the same time, both characters are heavily associated with the Avengers, giving Disney the right to use them so long as the words “mutant” or “Magneto” never came up. (Marvel went with another ‘m’ word — “miracle” — when introducing them in the post-credits scene of 2014’s Captain America: The Winter Soldier, teasing their debut in Age of Ultron.)

That also isn’t to say the relationship was antagonistic or inflexible. One such trade happened for 2016’s Deadpool and 2017’s Guardians of the Galaxy Vol. 2. For the former, screenwriters Paul Wernick and Rhett Reese really wanted to use the mutant Negasonic Teenage Warhead but change all of her powers and abilities. To do that, they needed approval from Marvel Studios, which in turn asked for the rights to Ego the Living Planet, a character closely tied with the Fantastic Four. So a swap was made, with the end result being two of the weirder movies either studio would ever make (and for Fox, in the case of Deadpool, the highest-grossing non-MCU Marvel film yet). Thank you, lawyers!

Haha yes that’s true. I don’t think Fox knew what a big piece of the cosmic universe puzzle he was going to be (and I had no backup ). https://t.co/Z19dDwvKgV — James Gunn (@JamesGunn) November 14, 2016

All of this became moot as of this week, when Disney finalized its purchase of 20th Century Fox, and with it, all associated Marvel IP.

Which properties are left for Marvel to reclaim?

While Disney’s acquisition has greatly simplified the Venn diagram of Marvel’s film IP, there are some characters who remain out of bounds for Marvel Studios — or characters that Marvel can use, but with very strict limitations.

Friends of Spider-Man

Though the MCU now has its own Spider-Man, Sony still retains the rights to an estimated 900 Marvel characters that it can use to make films that aren’t canonically in the MCU. That’s how a movie like Venom — which features Spider-Man’s long-tongued nemesis but is also not in the MCU — can exist, as well as its upcoming sequel and the Jared Leto vehicle with Morbius the Living Vampire. Those movies live in an adjacent universe and are likely to stay disconnected, at least for the current slate.

The Hulk — and She-Hulk — paradox

While Hulk can appear in MCU films, chances of a solo or headlining Hulk movie are pretty slim, as Kevin Feige reiterated to IndieWire around the time of Thor: Ragnarok’s release. Mark Ruffalo, who has played Bruce Banner and a motion-captured Hulk in each Avengers film as well as Ragnarok (and a brief Iron Man 3 cameo) was a bit more blunt, telling Variety, “I want to just make one thing perfectly clear today: A standalone ‘Hulk’ movie will never happen… Universal has the rights, and for some reason, they don’t know how to play well with Marvel. And they don’t want to make money.” The same logic, presumably, also applies to She-Hulk — at least until anyone says otherwise.

The Men in Black and Kick-Ass

Technically — and since we’ve already written 2,000 words on superhero IP, why not — both of these films are Marvel comics. Both Kick-Ass and Kingsman comics come from the Icon Comics imprint, and though Kingsman is now at Disney by way of Fox, neither of these properties has ever crossed paths with the MCU in any medium, and we don’t expect that to change. Same goes for Men in Black, which was originally published by Aircel Comics, which would later (in 1988) be bought by Malibu Comics, which would itself be bought by Marvel in 1994 ... but that’s also moot, because Sony owns the rights. Still, nice to see Chris Hemsworth in a suit.

Namor the Sub-mariner

One of the earliest Marvel Comics characters — originally published in 1939 — Namor falls in a similar complicated area as Hulk, in that Universal has some rights to the character. As Feige said to IGN last year, “I think there’s a way to probably figure it out but... it’s not as clean or clear as the majority of the other characters.”

Just this month, Doctor Strange director Scott Derrickson posted, and then quickly deleted, a comics screencap of Strange and Namor together. Whether that means anything, only a team of IP lawyers knows for sure.