Twitter’s stock surged to close at $39.77 on Tuesday, up 15.71 percent, after the company’s first quarter earnings report easily beat analysts’ expectations. The stock hit a high of $40.54 before settling down. It was trading at $39.85 after hours.

The spike brought Twitter’s market cap to $30.5 billion at the end of the day.

Twitter executives said the Q1 boost can be traced to the company’s campaign to eliminate spam and abusive posts while better targeting ads. The social media company said it has removed thousands of spam and suspicious accounts which it blamed for monthly user losses over the past quarters.

Twitter reported a Q1 profit of $191 million (25 cents a share) compared to $61 million (or 8 cents per share) in Q1 2018. Excluding a $124.4 million tax benefit, the company earned 9 cents per share.

It reported revenue of $787 million against the $776.1 million expected in the Refinitiv survey of analysts. Earnings per share came in at an adjusted 37 cents compared to 15 cents expected by Refinitiv.

Twitter listed 330 million monthly active users (MAUs), which excludes SMS users, compared to 318 million expected in a FactSet consensus estimate.

Twitter also announced a new metric called monetizable daily active users (mDAUs) to replace MAU starting Q2. It said mDAUs includes “Twitter users who log in and access Twitter on any given day through or our Twitter applications that are able to show ads.”

For Q1, the company reported 134 million average mDAUs compared with 120 million a year earlier. Twitter said it had 126 million mDAUs in the fourth quarter.

In the U.S., Twitter reported 28 million average mDAUs in Q1 compared with 26 million year-on-year. It reported 105 million average international mDAUs for the first quarter, compared to 94 million a year earlier.

Twitter, however, forecast lower second quarter revenue and warned of a hefty increase in operating expenses. It estimates Q2 revenue ranging from $770 million to $830 million against analyst estimates of $783.9 million to $853.6 million in Refinitiv.

Twitter again said it expects cash operating expenses to jump by 20 percent in Q2 compared to the similar quarter in 2018 as it continues to invest in “health, conversation, revenue product and sales, and platform.”

Twitter said it will strengthen its sales team in 2019 to better serve big advertisers.

“Something where you see a blending of performance and brand is the Star Trek ad that Disney is running right now, where I click through to make sure that I’d be notified when more information was available about the next Star Wars,” said CFO Ned Segal.