As Twitter (TWTR) roots out what management termed "spammy and suspicious accounts," a sequential decline in monthly average users spooked investors Thursday.

Twitter is using machine learning and artificial intelligence to reduce "spam, malicious automation and platform manipulation," co-Founder and CEO Jack Dorsey told investors during the company's second-quarter earnings call Friday. While monthly average users climbed nine million from the year before to 335 million, MAUs declined by one million from the first quarter.

Dorsey assured investors that Twitter's "health" program makes the network stronger and appeals to advertisers, yet shares plunged 19% to $34.81. Shares are still up more than 40% for the year. The rout recalled Facebook's (FB) epic 19% thud on Thursday, after the social network missed Wall Street forecasts for the first time in a dozen quarters and scaled back guidance.

To emphasize Twitter's increasin ability to drive event-related usage, Dorsey, a big Golden State Warriors fan, trolled Cleveland Cavaliers shooting guard J.R. Smith. "There were 72,000 tweets per minute at the end of game 1 of the NBA finals when J.R. Smith dribbled out the clock instead of taking a shot," Dorsey said on the earnings call. "#DubNation thanks you, J.R."

That moment you realize you probably blew the #NBAFinals #JRSmith #LeBronJames #YouAlmostWonGame1 #Whoops! pic.twitter.com/3QRyiBIVWx

- WCVB-TV Boston (@WCVB) June 1, 2018

The financial results were better than expected, suggesting that the efforts to improve the network appeal to advertisers are working. Earnings of 17 cents per share, on a non-Gaap basis, topped forecasts of 16 cents per share. Revenue grew 24% to $711 million, above consensus expectations of $697.9 million. 

Twitter purged tens of millions of accounts, CFO Ned Segal said. "Most of them, in many situations, were inactive" and had not been used in 30 days, he said. "Some of them never made it into the disclosed metrics because we are getting better at catching them at sign up."

Engagement of Twitter's base actually grew, however, as the number of daily average users increased by 11%. Twitter does not disclose the absolute number of DAUs.

"While debates around MAUs and forward revenue trends will dominate today, we still see TWTR as executing very well against its turnaround with a distinct repositioning around curated product, daily engagement, & video led engagement/monetization," Eric Sheridan of UBS wrote in a Friday report.

The World Cup soccer tournament, which stretched from the last two weeks of the second quarter to the first two weeks of the third quarter, was a focal point for Twitter's new approach to events. The social network emphasized scores and video highlights in the timeline, search and explore tabs.

The event generated approximately $30 million of total revenue and 115 billion impressions, the company said. Twitter is developing an events infrastructure to for future global and local happenings, such as the upcoming mid-term elections in the U.S., Segal added. 

In addition, to speed up the network cleanse, Twitter acquired anti-spam and security company Smyte during the second quarter.

The health of the network is at the top of Twitter's investment priorities, Segal said. Audience and engagement are second, followed by ad products and sales, Segal said. Twitter boosted its 2018 capex guidance from between $375 million to $450 million, to a new range of $450 million to $500 million. The spending reflects a $200 million "tech refresh" in Twitter's data centers.

Advertisers are less rattled by MAUs than investors are, apparently, as ad revenues grew by 23% to $601 million in the second quarter. Segal said that Twitter can continue to grow advertising in excess of the audience growth rates. Advertisers value "a healthier Twitter as opposed to a disclosed metric," he told investors. 

The health program, like security and privacy, is a long-term project. "We don't think this work will necessarily ever be done," Dorsey said.

Facebook is a holding in Jim Cramer's Action Alerts PLUS member club. Want to be alerted before Jim Cramer buys or sells FB? Learn more now.

More from Technology

The 2020 Mustang Shelby GT500 Is the Most Powerful Street-Legal Mustang Ever

The 2020 Mustang Shelby GT500 Is the Most Powerful Street-Legal Mustang Ever

AMD's CTO Tells TheStreet About the Chipmaker's Product Roadmap

AMD's CTO Tells TheStreet About the Chipmaker's Product Roadmap

Why Roku's Here to Stay According to a Real Money Contributor

Why Roku's Here to Stay According to a Real Money Contributor

As Techlash Grows, Microsoft's $500M Housing Pledge Is More Than Just Good PR

As Techlash Grows, Microsoft's $500M Housing Pledge Is More Than Just Good PR

Jim Cramer's Take on Netflix Earnings (and the Other FAANG Stocks)

Jim Cramer's Take on Netflix Earnings (and the Other FAANG Stocks)