After a series of disappointing quarters, Krispy Kreme (NYSE: KKD) has been on a road to recovery lately. What's contributing to the long-awaited turnaround?

The doughnut maker's second-quarter net income jumped fourfold to $8.8 million -- driven in part by a one-time gain on the sale of its stake in its Mexican franchisee for $4.7 million -- and shares surged in response. Revenues for the second quarter rose to $98 million, from $87.9 million a year ago. Krispy Kreme also posted a modest increase in same-store sales and a sharp increase in franchise revenue. While domestic franchise revenues rose by 13.3%, to $2.3 million, international franchise revenue posted an exceptional 33.5% growth to $5.4 million, mainly driven by increased royalty income.

The company also managed to keep costs low. Selling and administration expenses fell slightly, and interest expenses took a 75% nosedive on the back of favorable lending rates and reduced debt.

Despite mounting fuel and commodity costs, Krispy Kreme managed to improve its gross profit margins slightly, from 12.3% to 12.5%. The company's supply-chain division that makes doughnut mixes and doughnut makers turned in a solid 12% revenue increase on the back of product-price increases.

The company is also looking at more liquidity, with a consistent increase in its cash and equivalents, from $21.2 million in the second quarter last year to an impressive $32.3 million. Long-term debt of $27.7 million is down about a third from year-ago levels.

Krispy Kreme has plenty of competition, though. If it wants to regain its past glory, it needs to catch up with rivals such as Dunkin' Brands (Nasdaq: DNKN) and Starbucks (Nasdaq: SBUX). Krispy Kreme CEO Jim Morgan must breathe some life back into his still-somewhat-stale brand.

The Foolish bottom line
Krispy Kreme appears to be gaining momentum in terms of revenue and profitability. Given the trend over the last two quarters, I think the company will see brighter days ahead under Morgan's leadership. However, it will still have to grapple with Dunkin' and other competitors as it continues its turnaround.