Alon USA (NYSE:ALJ) is shaping up to be a big winner. Granted, success is easier when riding the raging tailwinds of the oil-refining market. But I believe this story has much more to do with how well the company manages its cash. Take a look at its smart acquisitions in the retail and refining segments. And keep in mind that in the midst of this booming market, Alon USA is sharing the cash with shareholders.

Raging tailwinds
Second-quarter results beat expectations thanks to strong refining margins. Excluding special items, Alon USA earned $0.89 per share, up 17% over the $0.76-per-share showing in the comparable year-ago quarter. The completion of an ultra-low-sulfur diesel project at the Big Spring Refinery reduced average throughput for the quarter to 55,720 barrels per day (bpd), compared with 71,602 bpd a year ago. However, the project is now complete, and the Big Spring refinery has returned to running at full rates.

The company was able to post positive results because margins made a huge leap over the first quarter and over 2005. The Gulf 3-2-1 crack spread (an industry measure of refining profit margins; link opens a PDF) increased to $18.22 per barrel versus $9.70 per barrel in the first quarter and $10.18 per barrel during the second quarter of 2005. The West Texas Intermediate/West Texas Sour crude differential (a.k.a. WTI/WTS, the difference in price between low-sulfur and high-sulfur crude oil) increased to $4.72 per barrel, slightly down from the first quarter but significantly higher than the $3.74 per barrel in 2005. This metric benefits Alon USA, because its Big Spring refinery operates with 90% high-sulfur, or sour, crude.

On the retail side, fuel sales continued the decline that began in the first quarter, but in-store sales continue to grow. Management claims that it's satisfied with these results, since the lower fuel sales are the result of a more aggressive pricing policy implemented in the first quarter. Because in-store margins are north of 30% and fuel sales are 6%, I'll take management at its word.

Managing the cash
The ultra-low-sulfur diesel project is a good example of how Alon USA manages its cash. The project was completed for $17.5 million, which CEO Jeff Morris indicated was about 20% of the cost for similar projects that other refining companies have completed. As a comparison, Frontier Oil (NYSE:FTO) paid $75 million to CB&I (NYSE:CBI) for the ultra-low-sulfur diesel project at Frontier's El Dorado, Kan., refinery, which has close to the same throughput as Alon USA's Big Spring refinery.

Investors should note, however, that no two projects or refineries are exactly alike. The El Dorado project may have cost more because the company achieved other objectives beyond meeting the ultra-low-sulfur diesel specification. However, the comparison does show that Alon USA met the specification for minimal capital expenditure.

Sharing the wealth
Beyond building profits with good allocation of capital, Alon USA has stated that it's committed to sharing the wealth with shareholders. In addition to the regular quarterly dividend of $0.04 per share, the company announced its second special dividend in the past six months -- this one for $2.50 per share, far surpassing the $0.37-per-share special payout in February. During the conference call, Morris said he prefers special dividends over share repurchases because the result to investors is direct. While some would debate the merits of special dividends, I'll take the cash.

The next chapter
Last quarter, I was hoping to pick up more shares if they fell below $30. I had my chance and failed to pull the trigger. Today, shares have advanced beyond the $40 level. While Alon USA is no longer cheap, this Fool thinks there's a long growth story emerging here.

In its short year as a public company, Alon USA has demonstrated that it can find attractive acquisitions. Once it has the assets, it can upgrade and increase the return from those assets. Two examples are the ultra-low-sulfur diesel project just completed, and the Big Spring refinery expansion it wrapped up last year for the price of $800 per barrel -- less than 10% of the price for expansions at other refineries. I anticipate that Alon USA will make similar investments to increase the throughput and value of products with its Paramount and Edgington Oil acquisitions.

While Alon USA remains a small player, its size should work to its advantage. Because of antitrust concerns, it will be difficult for giants such as Valero (NYSE:VLO) and ConocoPhillips (NYSE:COP) to expand their refining operations in North America. Conversely, Alon USA can continue to make acquisitions, expand its existing capacity, and deliver cash to investors for many years to come.

Alon USA has been a double since the beginning of the year. Although it isn't a Motley Fool Hidden Gems recommendation, it shares many of the same characteristics: inside ownership, a growing niche market, and management willing to deliver the cash to shareholders. To see all of our current Hidden Gems recommendations, which also happen to be beating the market, click here to sign up for a free trial.

Fool contributor Robert Aronen owns shares of Alon USA, but no other company mentioned. The Fool has a disclosure policy.