(Editor’s note: This story may contain language in paragraph 9 that may offend some readers)

SAN FRANCISCO (Reuters) - Tesla Motors Inc TSLA.O reported a steeper than expected quarterly loss on Wednesday on higher spending at its vehicle and battery factories, and said adjusted profitability could be within sight if the company meets its delivery goals.

The 13th straight quarterly loss for the Silicon Valley electric carmaker underscores the financial hurdles that hamper it while it takes on increasingly ambitious goals - a ten-fold ramp of vehicle production in three years and the recent plan to acquire solar panel installer SolarCity Corp SCTY.O.

Tesla, led by entrepreneur Elon Musk, said it was still on track to deliver about 50,000 new Model S and Model X vehicles during the second half of 2016, and reiterated that it would spend $2.25 billion in capital expenditures in 2016 to prepare for its upcoming Model 3 sedan.

If the company can fulfill those production and delivery goals in the second half of the year, “we’ve got a great chance of being non-GAAP profitable” Chief Financial Officer Jason Wheeler told analysts on a conference call without specifying a time period.

Tesla reported its first-ever quarterly profit in 2013.

Shares of the company, which has offered to buy SolarCity for $2.6 billion, were little changed in after-hours trading.

A prototype of the Tesla Model 3 is on display in front of the factory during a media tour of the Tesla Gigafactory which will produce batteries for the electric carmaker in Sparks, Nevada, U.S. July 26, 2016. REUTERS/James Glover II

“There’s no doubt Tesla will remain the category leader as electric vehicles become increasingly mainstream, but it could be years before the bottom line justifies any investment in Tesla other than a purely speculative one,” said James Brumley, InvestorPlace.com analyst.

Tesla reported last month it had missed its vehicle delivery target for the second consecutive quarter, raising doubts it would hit its annual target. But Tesla could end the year just shy of its original delivery target of 80,000 to 90,000 vehicles for 2016 if it delivers 50,000 cars in the second half of 2016.

“We were in production hell for the first six months of the year,” Musk told analysts during a conference call. “Man, it was hell. And we managed to climb out of hell partway through June and now the production line is humming and our suppliers mostly have their shit together.”

Musk warned he would fire suppliers and reorganize internal teams who fail to meet a target date of July 1 to begin production of the Model 3, even while acknowledging it will not be possible to meet that date.

The company said it planned to open a new store every four days on average for the rest of the year, including in Taipei, Seoul and Mexico City, but did not disclose the cost.

Excluding items, Tesla lost $1.06 per share in the three months ended June 30, wider than analysts’ expected loss of 52 cents per share, according to Thomson Reuters I/B/E/S.

Tesla said its net quarterly loss widened to $293.2 million, or $2.09 per share, from $184.2 million, or $1.45 per share, a year earlier. Total revenue rose 33 percent to $1.27 billion.

Click here for a graph on Tesla's results: tmsnrt.rs/1kpNS9J

Tesla said gross margins will improve by 2-3 percentage points in the second half of the year, although adjusted operating expenses will increase for the full year by 30 percent.

Musk sketched out an ambitious plan last month to venture into manufacturing electric trucks and buses, as well as expanding the company’s solar energy business.

He has cast the SolarCity tie-up as a long-term bet on a carbon-free energy and transportation company that provides cars, battery storage, solar panels and other energy solutions, while leveraging technology and cost savings from the combined entity.

SolarCity’s chairman and biggest shareholder, Musk has said the combined company will help save at least $150 million a year and require only a “small equity capital raise” next year. But some analysts are wary of the combination of two companies burning through huge amounts of cash.

Tesla unveiled its massive battery factory, the Gigafactory, in Nevada last week, and on the conference call, Musk said he foresees “exponential growth” in Tesla’s storage battery business.