New York (CNN Business) Even after delivering a record number of cars in its second quarter, Tesla (TSLA) is still bleeding money. Tesla said Wednesday that it lost $408 million during the three months ending in June, far worse than Wall Street had expected. Shares of Tesla fell more than 10% in after hours trading following the earnings report.

The loss was slightly less painful than the previous quarter, in which Tesla lost $702 million . The company attributed its performance to record vehicle delivery numbers of more than 95,000 cars. That was up nearly 5% from the previous record in the fourth quarter of 2018. It also said some of the quarter's losses were because of one-time operating expenses and currency fluctuations.

CEO Elon Musk announced on a call with analysts Wednesday afternoon that J.B. Straubel, a founding member of the company, is stepping down from his role as chief technology officer and will become a senior adviser. Current vice president of technology Drew Baglino will take on most of Straubel's responsibilities.

"It's been quite an adventurous 16 years," Straubel said on the call. "This is not some lack of confidence in the team or company or anything like that."

The company reported improved margins for its best selling car, the Model 3. Though it cut the starting price for the Model 3 in February , the average selling price for the car remained stable in the second quarter at around $50,000 and manufacturing costs declined, Tesla said.

Read More