Tesla is on a roll.

After recording a $1.1 billion loss in the first half of 2019 and seeing its stock price tank to $180 per share, the electric car company has come roaring back, boasting profits in both the third and fourth quarters of last year. Tesla sold 367,500 cars in total in 2019 — more than it sold in 2018 and 2017 together. Its stock price blasted past $400 per share around the start of 2020, closing at almost $570 per share earlier this week. That tipped Tesla over the magic threshold of a $100 billion stock market valuation.

How Tesla achieved this turnaround is an oddball story. It involves a very unusual compensation package for its brash and controversial CEO, Elon Musk; a long history of complaints about working conditions; and a very big tent in a parking lot in California.

The story starts with the Model 3. The most stripped-down version of the car, with the fewest bells and whistles, currently goes for $39,500. Not exactly cheap, but more affordable than Tesla's other vehicles, which tend to go for $70,000, $80,000 and up. The Model 3 was supposed to break Tesla into the broader consumer market.

Ultimately, it seems to have worked: Model 3s were 80 percent or more of Tesla's sales in the fourth quarter of last year. But getting the production line up and running, absorbing the massive list of Model 3 pre-orders, while expanding new operations in China and Europe, and getting some other models going (like the Model Y SUV and the bizarrely techno-futuristic Cybertruck) was almost more than the company could chew. Musk called it the "most difficult logistics problem [he'd] ever seen."

Tesla was bleeding hundreds of millions at the start of 2018, trying to keep all these balls in the air. The company became profitable in the second half of 2018, then went into the red again as 2019 rolled around, before finally recovering a second time. Of course, that roller coaster made Tesla's stock one of the most exciting and controversial around: About 20 percent of Tesla's shares are being shorted; which is to say, traders are using the shares to make bets that the company will eventually tank. Nor was investors' heartburn helped by Musk's own behavior: He had to temporarily step down as chairman of the board after his tweeting got him in trouble with the Securities and Exchange Commission (SEC).

Two years ago, to demonstrate his seriousness, Musk agreed to an extremely unusual pay package: He won't take a salary, but if he can hit various market value thresholds — starting at $100 billion, and going up in increments of $50 billion to $650 billion — he'll get bigger and bigger stock payouts. Having just hit the $100 billion mark, Musk has the option to buy about $370 million worth of stock. If he can hit the final $650 billion threshold, Musk could be rewarded with $55 billion in stock.

Tesla is hardly out of the woods yet. Its profitability may likely dip again, the SEC still has its eye on the company, and highway safety regulators are investigating crashes possibly linked to the autopilot in Tesla's cars. But as of now, despite all the ups-and-downs, the company's total market value is greater than General Motors and Ford put together.

A big part of how it got there is just good old-fashioned working the problem: Getting its investments set up, smoothing out the production process, and trusting in its long-term plan. "Operating expenses are at the lowest level since Model 3 production started," the company claimed in October. It also said it had "dramatically improved the pace of execution and capital efficiency of new production lines." But Tesla also had to get creative, as evidenced by the tent.

Literally, it's a tent covering 137,250 square feet, or roughly two and a half football fields, in the parking lot of Tesla's Fremont, California factory. Referred to as GA4 (general assembly 4), the tent was meant to be an extra assembly line, more or less slapped together ad hoc in mid-2018, so that Tesla could meet its then-overwhelming production goals. Obviously, GA4 was supposed to be a temporary solution, but as of now it's still up there, currently cranking out about a fifth of the company's Model 3s.

It's also a strikingly old-school operation: Rather than advanced robotics putting the cars together in GA4, the assembly line is mainly conveyor belts leading to various stations, with lifts so that workers can get to the automobiles and put them together with repetitive manual labor power tools. As of July 2019, the tent could produce 120 cars per shift, at three shifts per day. "It's extremely unusual, at a minimum," Michael Ramsey, an automotive analyst at Gartner, once mused to Business Insider. "I've never heard of anyone ever doing this before on a grand scale."

There is also a potential dark side to Tesla's turnaround. Needless to say, any company facing these kinds of pressures is going to be tempted to cut corners. Reports allege that some of the tent's production has involved things like tape to quickly fix plastic housings for electrical wiring, and skipped vehicle tests. More troubling is additional allegations of poor working conditions: GA4 assembly line workers having to deal with cold temperatures at night without adequate heating, rain leaking through the tent, and doing shifts under shoddy air quality caused by the California wildfires. Tesla was in fact slapped with a modest $29,365 fine by California's Division of Occupational Safety and Health over issues with GA4, though a University of Michigan professor who helps automakers improve their manufacturing processes told Business Insider the violations were common in the auto world.

This also comes on top of a longer history of complaints about work conditions and injury rates at Tesla's various factories, not to mention the company's general hostility to unions. For its part, Tesla argues it's greatly improved work conditions and injury rates over the last few years, and now does better than the industry average. Of the complaints about the tent specifically, the company says a few isolated anecdotes are "misleading and do not reflect our manufacturing practices or what it's like to work at Tesla."

But if the he-said-she-said nature of Tesla's worker treatment should remind us of anything, it's that celebrations of capitalist hustle and drive and triumph in the face of enormous obstacles is not always a straightforwardly good thing. By all accounts, Musk is motivated by far grander ambitions than simply making money — like going to space and tackling climate change. But even that sort of higher vision has its price, which is usually paid by the everyday workers and the people with less power.

Marvel at Tesla's turnaround, by all means. But exercise some caution as well.

Want more essential commentary and analysis like this delivered straight to your inbox? Sign up for The Week's "Today's best articles" newsletter here.