Since going public almost four years ago, Twitter has been bleeding red ink. That has been due, in large measure, to its profligate awarding of stock options to employees.

Yes, every Silicon Valley company, public or not, does it. Stock options seem magical because they’re like free money. You give them to employees, and it’s the stock market that (eventually) pays for them.

But in reality, stock options have a cost. As a company awards more of them, it dilutes the value of shares held by all the other existing stockholders. And that means the company is required to account for them as an expense, even if it spends no actual cash.

Twitter’s IPO was in November 2013, and the cost of the company’s stock-based compensation has at times grown to epic, almost ludicrous proportions. In the second and third quarter of 2014, for instance, the value of that stock-based compensation was $158 million and $169 million, respectively, or 51 percent and 47 percent of the company’s ENTIRE REVENUE.

It’s pretty tough to turn a profit under those circumstances. The expense has been driven by stock awards to rank-and-file employees, but also to execs. In 2014, CFO Anthony Noto, who recently announced he was leaving, received a compensation package¬†valued at $72.8 million for the six months he worked at Twitter that year.

Twitter has long been taking in more cash than it spends, so its survival has never really been in question. But this is all worth noting today as the company celebrates its first ever profitable quarter.

Twitter’s stock soared 20 percent in pre-market trading, largely based on that news. MAUs were actually down from a year ago. Revenue growth was decent. But it was the profit that caught everyone’s attention.

As Twitter explained in a filing with the U.S. Securities and Exchange Commission, it was a drop in stock-based compensation that drove a large decrease in expenses and allowed Twitter to finally become profitable:

“Total GAAP expenses in Q4 declined 28 percent year-over-year to $621 million, reflecting our more efficient cost structure and a 26 percent decrease in stock-based compensation (SBC) expense year-over-year and resulting in a GAAP net margin of 12 percent,” the filing notes.

In raw numbers, stock-based compensation fell from $138 million one year ago to $102 million. In the coming quarter, Twitter expects that number to be between $100 million and $110 million.

To be sure, CEO Jack Dorsey and soon-to-be former CFO Noto deserve credit for weaning the company off this addiction. Laying people off also helps, of course. But what really seems to have done the trick is taking a more disciplined approach to stock-based compensation, even in the face of the wildly competitive Silicon Valley job market.

With this issue diminishing, shareholders will also get a clearer picture of the company’s actual turnaround progress. And there has been some progress. With more cash coming in the door, Twitter has the resources to soldier on, more than a year after it failed to find a buyer.

Now it can get back to building a business that’s again¬†worthy of the adoration and trust it once inspired.