Tesla turned a surprise profit in the first quarter of 2020 of $16 million, despite factory shutdowns in China and the US, the company announced on Wednesday. It said it may still hit its goal of delivering 500,000 vehicles worldwide this year even in the face of the pandemic. It’s the first time in Tesla’s history that the company has turned in three consecutive profitable quarters.

There are, of course, caveats to those statements. Tesla sold $354 million worth of regulatory credits in the quarter, a record for the company. And while Tesla said it has the capacity to beat that 500,000 delivery goal, the company admitted that it “remains uncertain how quickly we and our suppliers will be able to ramp production after resuming operations.”

It wasn’t necessarily just financial engineering that helped Tesla turn the quarterly profit, which is just its fifth in the last three years. Tesla had already announced that it was able to keep delivery and production numbers up during the first quarter despite facing the early impacts of the pandemic.

The Tesla Semi is delayed to 2021

The Model Y also started shipping this past quarter (ahead of schedule, no less), and Tesla says it’s already making the company money, marking the “first time in [Tesla’s] history that a new product has been profitable in its first quarter.” That’s not only because the Model Y shares 75 percent of its parts with the Model 3, but also because Tesla is using some of the Model 3’s production lines to build the Model Y.

The company also generated $5.9 billion in revenue, which is an increase of nearly $1.5 billion compared to its first quarter performance in 2019 and about $100 million higher than was expected from Wall Street analysts. Tesla says it made a gross margin of 25.5 percent on its vehicles, which is the highest that figure’s been since the height of the ramp-up of Model 3 production. The company finished the quarter with $8.1 billion of cash.

Not everything is going according to plan, however. Tesla said on Wednesday that it is delaying the first deliveries of the Tesla Semi truck to 2021. The Tesla Semi was first revealed back in November 2017, though its development has taken a back seat to products with broader appeal and more immediate bang for the company’s buck.

And while Tesla’s new factory in China is back up and running, the company’s main automotive plant in California has been shut down for all of April, meaning that the company’s second quarter results are likely to look a lot worse than the ones announced on Wednesday. Tesla has already furloughed hundred, if not thousands, of workers and cut salaries across the company as a result.

Elon Musk is “worried about not being able to resume production in the Bay Area”

To that end, shortly before the company announced the first quarter results, public health officials in the San Francisco Bay Area announced that they’re extending the shelter-in-place order for the region through May 31st. While some businesses are allowed to reopen, automotive manufacturing is still not considered to be an “essential business,” according to the revised text of the order.

Tesla resisted the shelter-in-place order when it was first announced in mid-March. The company said at the time, to both employees and local officials, that it was told by the Department of Homeland Security that it was deemed “national critical infrastructure,” despite the fact that other automakers were suspending their operations at the time.

“We are a bit worried about not being able to resume production in the Bay Area, and that should be identified as a serious risk,” Musk said on a call with investors Wednesday night. He then went on to call the orders “fascist” and said that local governments around the country are “forcibly imprisoning people in their homes against their constitutional rights in my opinion, and breaking people’s freedoms in ways that are horrible and wrong.”

Update April 29th, 7:39PM ET: Added comments from the investor call.