Drugstore retailer Rite Aid (NYSE:RAD) has been a work in progress for as long as investors can remember. Fools may be wondering whether the company will ever blossom into a savvy operator, much like its larger rivals. But a solution now seems to loom, and other potential improvements could spell big gains for investors.

Rite Aid eked out a fourth-quarter gain in earnings it released Thursday, but analysts found the results disappointing. The full-year results weren't so hot, either, as the company posted another year of charges from store closings, impairments, "loss on debt modifications and retirements," and other losses from selling assets and investments. At least six straight years of income tax benefits illustrate just how accustomed the company is to special charges.

Rite Aid is also highly leveraged after years of restructuring its own stores and acquiring other drugstores. Its debt-to-capital ratio is high, at more than 60%, and will soon grow larger. Shareholders recently approved the pending purchase of 1,850 Brooks and Eckerd stores from Jean Coutu Group. Once the purchase closes, Rite Aid will have more than 5,000 stores, putting it closer to Walgreen (NYSE:WAG) (more than 5,500) and CVS (NYSE:CVS) (more than 6,000).

Because of all of these factors, it's difficult to discern just how profitable Rite Aid is or will be going forward. It does post similar gross margins to its two larger peers, and its same-store sales trends are encouraging -- they just grew 3.4% for all of fiscal 2007 -- but its operating and net margins are much lower on a reported basis. It will soon have the store base to compete in an industry that increasingly favors scale, but the acquisition adds a lot of uncertainty.

For the time being, Rite Aid is no match for Walgreen, with its industry-leading profitability and unmatched organic growth. It also can't come close to matching CVS' proven ability to successfully integrate acquisitions. But with any value play, there is substantial room for improvement. And if Rite Aid can improve its net margins, reduce debt, and smoothly integrate its latest acquisition, the stock's upside would be substantial.

For related Foolishness:

Need new ideas for your money? Investors like you rate thousands of stocks on Motley Fool CAPS to help you with your own stock selections. It's fun --and it's free.

Fool contributor Ryan Fuhrmann is long shares of Walgreen but has no financial interest in any other company mentioned. The Fool has an ironclad disclosure policy. Feel free to email him with feedback or to discuss any companies mentioned further.