After an erratic few months for Elon Musk, the Tesla CEO finally seemed focused on Wednesday.

The electric car company held its second-quarter earnings call, during which Musk discussed a period that saw the company beat Wall Street revenue expectations but post wider losses than expected. One of the big questions heading into the call was whether Musk was going to stay on script, something he's never been very good at doing.

Three months ago, Musk baffled shareholders, analysts, and reporters during a bizarre first-quarter call in which he ranted against the media and cut off questions about the company's financials to take questions from a YouTube vlogger. One Morgan Stanley analyst called it the "most unusual" call in his 20-year career on Wall Street.

The first two questions Musk took Wednesday came from analysts whom he was especially rude to last time around. In May, Bernstein analyst Toni Sacconaghi asked Musk about the company's need to raise money. Musk declined to answer, saying, "Boring, bonehead questions are not cool."

This time, he showed some much-needed emotional intelligence. "First of all, I'd like to apologize for being impolite on the last call," he said. "I had gotten no sleep and working 100-, 120-hour weeks. But that's no excuse." 

The next question came from Joe Spak of RBC Capital, whom Musk interrupted last time before taking the remaining questions from a 25-year-old aspiring analyst. Musk apologized to Spak as well before answering his question. 

The focus and seriousness was likely a welcome change for Tesla shareholders. Musk has found himself embroiled in controversy recently, almost entirely by his own doing. He referred to a British diver helping with the rescue of a youth soccer team in Thailand as "pedo guy" after the diver contested that Musk's invention to extract the team wouldn't work. He also posted--and soon deleted--a racy GIF of Miley Cyrus twerking, and on another occasion tweeted about drinking on Ambien.

All this comes at a time when Tesla is racing to fulfill its Model 3 orders. The company has repeatedly pushed back its manufacturing targets for the vehicles, for which Tesla has received an estimated 400,000 orders.

In July, the company hit an important milestone, producing 5,000 models in one week--a figure Musk had long been pursuing. Last summer, he said he hoped to achieve the goal by the end of 2017. 

In a letter published Wednesday, the company said it hopes to reach 6,000 cars per week sometime in August.

Revenue hit $4 billion in the second quarter. Wall Street had predicted $3.92 billion. The company's losses were wider than expected: $3.06 per share versus an estimate of $2.88.

Musk didn't show particular focus leading up to the earnings call. Earlier this week, he announced the sale of $1,500 Tesla surfboards, which many on social media labeled as a distraction. Earlier in the day Wednesday, he tweeted that the next Tesla software update would contain Atari games as hidden Easter eggs.

In its letter, Tesla said the Model 3 outsold all other premium cars on the market combined in the month of July. Musk said during the call that he has "high confidence" that the company will be cash-flow positive in the third quarter and every quarter moving forward.

Whether or not it will last, investors seemed to like Musk's new attitude: Tesla's stock rose 5 percent, to $332, in the first 35 minutes of the earnings call Wednesday.