"The Lego Movie" premiered last Friday and made $69 million in its opening weekend, giving it the largest debut of the year so far. Yet only 10 years ago, the company was on the brink of bankruptcy, and such a massive undertaking (let alone a successful one) would have been out of the question.

When Jorgen Vig Knudstorp came in as Lego CEO in 2004, the company was struggling to give consumers what they wanted and effectively manage costs. Knudstorp finally brought fiscal responsibility to the Danish toy maker. He also tried something novel -- handing over creative direction to the core fans of the brand.

It worked. Creativity combined with smart management ultimately saved the company.

Lego Designer Mark Stafford, a fan who was recruited to help rethink the company's products, recently took to Reddit to share some of the behind-the-scenes details of the turnaround.

When Stafford attended an AFOLCon (Adult Fans of Lego Convention) event in the United Kingdom a couple years ago, he heard Lego's chief marketing officer Mads Nipper speak about the terrible period between 1999 and 2003. Stafford writes of it:

The LEGO company at that stage had no idea how much it cost to manufacture the majority of their bricks, they had no idea how much certain sets made. The most shocking finding was about sets that included the LEGO micro-motor and fiber-optic kits -- in both cases it cost LEGO more to source these parts then [sic] the whole set was being sold for -- everyone of these sets was a massive loss leader and no one actually knew.

Here's an image from eBay of one of those motorized kits. The "fiber optics" are actually clear plastic tubes that connect to a battery-operated LED-light pack:

How Lego Came Back From the Brink of Bankruptcy
The specialized motors and lighting packs cost the company more to produce than the kits were sold for.
Image credit: Screenshot, eBay

Stafford continues:

This was combined with a decision to 'retire' a large number of the LEGO Designers who had created the sets from the late 70's through the 80's and into the 90's and replace them with 30 'innovators' who were the top graduates from the best design colleges around Europe. Unfortunately, though great designers they knew little specifically about toy design and less about LEGO building. The number of parts climbed rapidly from 6000 to over 12,000 causing a nightmare of logistics and storage and a huge amount of infrastructure expansion for no gain in sales. Products like Znap, Primo, Scala and worst; Galidor all came out of this period.

That "Galidor" series he mentions with such disdain was based off a kid's show of the same name. It involved so many new parts exclusive to each individual set that it resulted in awkward kits that did not comfortably fit into the Lego brand. Here's one being sold on eBay:

How Lego Came Back From the Brink of Bankruptcy
Stafford considers the Galidor series to be Lego's biggest failure.
Image credit: Screenshot, eBay

The only reason Lego survived during this difficult time was due to the success of the Bionicle and "Star Wars" series. The first "Star Wars" Lego kits launched in 1999 and represented the company's first foray into licensed series, many of which became integral to the company, as this infographic from Wired illustrates. But Lego could not survive on several big sellers alone.

Knudstorp, a former McKinsey consultant, took charge of the foundering company in 2004 and immediately got to work. Stafford explains:

Jorgen Vig was put in charge, he made the hard call and made redundancies, they slashed the number of parts down to 6000 (a figure that has grown, but we're still below well below the 2003 total) -- the company reorganized and analyzed all costs, design was finally linked to manufacturing cost and re-focused on the core business of making construction sets. The unprofitable LEGO Computer games business was shut down. (Some of these guys returned to the UK and started their own company called Travellers Tales, they then licensed the LEGO computer game business and freed from LEGO management (who know nothing about computer games) they still make the LEGO computer games today -- making good money for all involved -- including LEGO.)

After consolidation and streamlining, Knudstorp led a charge to put creative control into the hands of hardcore fans of the brand rather than in those of top designers who had skills but lacked a real understanding of Lego's history. The company held its first designer recruitment workshop in Sept. 2006. Writes Stafford:

I was one of the 11 designers hired at that time, new managers were in place in the Design building, all developed inside the company, these guys loved the product, they knew the customers as they had grown up playing with LEGO and they had ideas that had been restrained for years. They hired several kid focused design graduates and a few AFOLs (adult fans of LEGO), of which I was one.

Stafford is one of the designers of the "Legends of Chima" series, which has an accompanying animated television show. The kits feature plenty of new parts and characters but never venture beyond the classic Lego "feel" that designers like Stafford helped bring back to the brand. Here's an example, from Lego's website:

How Lego Came Back From the Brink of Bankruptcy
One of Stafford's creations.
Image credit: Lego.com

For Stafford, the best proof of Lego's turnaround is captured by the new movie:

For me it's been an absolutely fantastic seven years so far and I see all of the work and principles these guys have created as the message of The LEGO Movie, it's not just a toy, it's a tool for creation and imagination and getting LEGO bricks into the hands of kids is the only aim of everything we do. I'm so proud of being even a tiny bit involved in it!

Here's a trailer for the film:

This story originally appeared on Business Insider