Amazon.com Inc. has been known for years as a company that brings in a lot of money, and sends it back out the other way just as fast.

That is why Thursday’s earnings report was especially surprising, as it showed a whopping $2.5 billion in quarterly profit for a company that had never produced as much as $2 billion in earnings in a single quarter before. When asked on a conference call by surprised investment analysts, who were predicting about half as much profit from the e-commerce giant, where all that money came from, Chief Financial Officer Brian Olsavsky summed it up pretty easily: Less spending, especially on new hires, and more ad sales.

“One thing that you’ll notice is that we’ve stepped down our rate of growth of fixed head count, excluding acquisitions,” Olsavsky noted, adding that Amazon has been shifting employees to areas of need instead of hiring from the outside.

A peek at the numbers shows a drastic reduction in comparison to last year. In 2017, Amazon added an astounding 225,000 workers — with about 90,000 of those coming over in the acquisition of Whole Foods Market — for workforce growth of more than 65%. So far in 2018, Amazon’s employee count has grown from 566,000 to 575,000, growth of about 1.7%.

See also: The typical Amazon worker made less than $30,000 in 2017

“We don’t think that that’s necessarily the long-term trend, but it certainly created a lot of operating efficiency and that will reset and evaluate where we need to still add people,” Olsavsky added.

The hiring slowdown was part of what Olsavsky termed “better-than-expected efficiencies in operations infrastructure costs and generally all of our fixed costs,” which basically means less spending. He also noted a slowdown in new leases and capital expenditures, a big expense as Amazon has been building out data centers for Amazon Web Services and fulfillment centers for its e-commerce operations.

Overall, Amazon is still spending plenty: It recorded operating expenses of $49.9 billion in the second quarter, an increase of 33.7% from the year before. Amazon revenue grew 39.3%, though, as net sales topped $50 billion for the third consecutive quarter.

Olsavsky also pointed out the growth of a high-margin business that many don’t realize Amazon has: Online ad sales. As MarketWatch reported last month, Amazon is making billions of dollars from digital advertising as marketers seek to reach the large number of Prime members and other shoppers who frequent the company’s website and mobile apps.

How voice-assistant software can revolutionize the entire household

“It’s now a multibillion-dollar business for us,” Olsavsky said, mentioning that there are now hundreds of thousands of Amazon advertisers. “We’re seeing strong adoption across a number of fronts. Amazon vendors, sellers, authors as well as third-party advertisers who want to reach Amazon customers.”

Amazon reported $2.19 billion in “Other” revenue — which is predominantly ad sales — in the second quarter, up 129% from the year before. That increase is a little misleading, as an accounting change at the beginning of the year meant that Amazon reports gross ad revenue instead of net; investor-relations executive Dave Fildes disclosed that the change inflated the figure by $640 million. Still, that would mean revenue of more than $1.5 billion, when Amazon recorded less than a billion dollars in the same quarter a year ago.

Don’t miss: Investors keep underestimating growth in internet advertising at their peril

Like AWS, ad sales are a high-margin business, as it does not require a lot of employees nor materials to sell an ad or rent out computing power. AWS has been powering Amazon profitfor years, and now it looks as though Amazon has another business that can expand the retail business’s typically razor-thin margins.

“There’s still a lot of runway for both of these higher-margin businesses, and with the rest of the business continuing to fire on all cylinders, the question now is whether we’ll see Amazon hit a $1 trillion market cap sooner rather than later,” eMarketer Principal Analyst Andrew Lipsman said in an email.

EMarketer believes Amazon’s net ad revenue will grow 58% this year to $3.37 billion, which would still give the company only 1.2% of the global market for digital ads. It is a long way from online-ad titans like Alphabet Inc. GOOGL, +0.95% GOOG, +0.92% and Facebook Inc. FB, +0.20% , but heading in the right direction.

See also: Thanks to Amazon Prime Day, the back-to-school shopping season is already under way

Amazon is Amazon, though, so it will likely spend more in the future, potentially even on the ad business. Olsavsky noted that the company had a long way to go in improving the tools that ad buyers use, including measurement of the performance of those ads, and that Amazon is working on new offerings in that area.

Amazon has never shown reticence to spend when it needs to, and the slowdown in spending in the first half of 2018 could be a momentary blip until the company starts spending in preparation for the holiday rush or picks some new projects to spend big on, such as new ad products. If it continues to run more efficiently while adding high-margin businesses to its high-revenue e-commerce division, though, Amazon has the potential to be a profit monster.