Twitter’s stock soared nearly 10 percent after the social network said moves to ban bots and bad actors are luring new users and advertisers.

The San Francisco-based company’s quarterly results on Friday beat Wall Street’s expectations on revenue, raking in $841 million against predictions of $829 million, as it purged millions of spammers and fake accounts.

The crackdown — which has been aimed at accounts that promote hate speech and political misinformation — has been closely watched by investors, as it helped drive declines in Twitter’s monthly users through much of last year.

In April, President Trump complained to Twitter CEO Jack Dorsey during a White House visit that his number of followers had decreased, with Dorsey reportedly blaming the broad crackdown on bots.

On the positive side, Twitter said instances of suspicious behavior and spam dropped by 18 percent during the second quarter.

Twitter has been trying to improve what the company calls the “health” of conversations on its platform amid widespread criticism that it doesn’t do enough to remove hate speech, abuse and harassment.

In a call with analysts, Dorsey — who famously adheres to a strict diet that allows him only one meal per day and requires that he fast all weekend — said “health” remains the top priority.

“Health is a long-term growth factor for us, and we have been doubling our efforts to make sure that we can address all the issues that we’re seeing on the service,” he said.

“A big focus for us over the past year has been to proactively identify content on Twitter that would violate our rules, so that we don’t require a report.”

But the push to cut down on fake accounts costs money, and its adjusted profit fell 36 percent to $37 million.

The revenue surge was driven by higher ad sales. The company is on track to hire 20 percent more people than last year, including in the sales staff.

Twitter earlier this year switched from a monthly user count to something it calls monetizable daily active users, meaning users who log onto Twitter at least once daily and see advertisements on the platform.

Its monetizable daily active usage hit 139 million, beating analyst expectations of 135 million.

Also on Friday, shares of Google parent company Alphabet soared nearly 11 percent on a stellar earnings report where it beat expectations across the board.

The jump represented Alphabet stock’s best day in four years, and saw the search giant add more than $80 billion to its market cap, bringing it close to $900 billion.