Just when it looked like the largest of Southeast Asia’s internet firms was yet another poster child of cheap money, a bubbly startup that had grown too much too fast, Sea Ltd.’s top executives took an ax to costs.

They closed down some Latin American operations, cut jobs, sacrificed their own salaries and squeezed nearly $500 million out of the promotional expenses at their e-commerce unit.

The result? A surprise quarterly profit for the company, the first in its history as a publicly traded firm since 2017. Shopee, the popular e-commerce wing, made the turnaround possible. It went from a nearly $900 million cash loss a year earlier to an Ebitda of almost $200 million in the December quarter.