Tesla Motors reported a much worse than expected loss of $282.3 million Wednesday as it struggles with the heavy cost of rolling out its Model X utility vehicle and sees much of its expected sales for the year coming in the last six months.

But the stock rallied in after-hours trading as investors focused on the electric car-maker’s adjusted earnings, which exclude expenses related to stock-based compensation and the way the company books revenue from leased vehicles. Tesla maintained its target of at least 80,000 unit sales for the year, and also said it’s moving its target of building 500,000 cars from 2020 to 2018.

“Increasing production five fold over the next two years will be challenging and will likely require some additional capital, but this is our goal, and we will be working hard to achieve it,” CEO Elon Musk and Chief Financial Officer Jason Wheeler said in a letter to shareholders released after markets closed Wednesday in New York.

The company’s stock price (NASDAQ:TSLA) gained 4.7 percent to $22.56 after the closing bell, erasing losses for the day that came after news of two executive departures linked to production problems with the Model X utility vehicle.

Tesla’s earnings report can be tricky, because the company’s numbers vary significantly between its pro forma numbers, which exclude certain expenses, and the figures it’s required to report to the U.S. Securities and Exchange Commission.

Tesla reported a GAAP loss of $282.3 million, or $2.13 per share, compared to a loss of $154.2 million, or $1.22 per share, in the same quarter last year. Analysts polled by Thomson Reuters ahead of the earnings release had expected a GAAP loss of $77.7 million or 86 cents per share, so the company had a huge miss there.

But Tesla’s first quarter adjusted (non-GAAP) loss was $75.3 million, or 57 cents per share, wider than the $45.3 million, or, 36 cents per share in the first quarter last year. The Wall Street consensus was for a loss of $83.7 million, or 58 cents per share. (Adjusted losses remove stock-based compensation, interest on borrowing and the way the company accounts for leased cars.) The earnings beat, as it’s called, is what sent the stock price upward after the bell.

Tesla also met revenue estimates for the first three months of the year, of $1.6 billion compared to $1.1 billion in the year-ago quarter. Meeting revenue expectations is one of the most vital metrics because it reveals sales growth for an otherwise non-profitable, money-bleeding company.

The increasing use of so-called non-GAAP (or pro forma) figures is facing increased scrutiny from regulators for the way companies define “one-time charges,” including executive stock-based compensation and — in Tesla’s case — the way it books profit from vehicle leases under its buyback guarantee, which poses measurable risk if the company can’t sell pre-owned cars for the price it expects in the future.

The earnings release came hours after Bloomberg reported the departures of Greg Reichow, Tesla's vice president of production, and Josh Ensign, vice president of manufacturing. The executive exits are related to delays and production problems with the Model X utility vehicle, which was highlighted in a Consumer Reports article last month.

Jim Chanos, a well-known short-seller (investors who profit when company share prices fall), later went on CNBC to say Tesla’s string of executive departures is a red flag. Other executives, including James Chen, vice president of regulatory affairs, and Ricardo Reyes, vice president of global communications, have left the company.

“One of our historical signposts is when numbers of senior people leave over a short period of time,” Chanos told the news network. “Tesla fits that bill. We have a chart of senior executives leaving Tesla; it is a flood in the last few years. This is not just Model X; these people are going to be needed for the Model 3.”