Who said companies in the oil and gas industry can't make money today? Because this past quarter, HollyFrontier (NYSE:HFC) posted an much better-than-expected quarter that will probably make several investors want to revisit the idea of adding this refiner to their watchlist. Let's take a quick look at the numbers and how HollyFrontier was able to produce such a fantastic result. 

Just the facts
Total net income per share came in at $1.88 per share, which was more than double per share earnings for this same quarter last year. Also, per-share earnings were well beyond the consensus estimates of $1.31 compiled by S&P Capital IQ. Even though revenue for the quarter was down 31% to $3.7 billion, the company was able to more than make up for it as the cost of its products sold was down 38%. 

This is one of the tricky aspects for an investor to evaluate companies in the refining and other midstream services. Revenue and cost of products are both based on commodity prices. In the case of HollyFrontier revenue is the price per barrel of refined products such as gasoline and diesel, and the cost of products sold is the price per barrel for the crude oil it refines. This difference is commonly known as the crack spread, and for this quarter the crack spread for the company was $17.72 per barrel of refined products, a 20% increase from this time last year.

What is just as important to the company's bottom-line results was its cash generation in the quarter of $326 million, which based on current capital spending rates is well above what is needed to meet its capex and its dividend payments. During the quarter, it also repurchased $325 million of its own stock. The extraordinary number of shares repurchased this past quarter were part of an accelerated share repurchase program, which tapped some of the company's cash and short-term investments. At the end of the quarter, HollyFrontier, excluding the debt held by its master limited partnership, remained debt-free and has $626 million in cash and short-term investments on the books. 

Making the best of one's environment
So much of a refinery's success is determined by that crack spread number. For the most part, companies in the refining space are beholden to the market forces that determine the price of crude and refined products. That doesn't mean, however, that a company is unable to tweak operations around the margins to improve their crack spread; and this quarter was an example of that for HollyFrontier.

Refiners can improve the crack spread in two ways: Find a way to source cheaper crude oil, and get higher revenue per barrel of refined products by changing the production mix. And, not surprisingly, HollyFrontier was able to do both this quarter. It was able to reduce its crude costs not just from the overall lower crude price environment, but also by decreasing its use of the most expensive types of crude oil -- sweet crude -- and increasing its use of lower-quality crudes -- sour crude.

At the same time, the company was able to improve its product mix by increasing its yield of gasoline and diesel -- the highest price refined products -- by 4 percentage points to 88% of total refined content. These two effects are in large part due to the regular capital investments that management has made in its refineries over the past years. By adding new, complex refining units that can turn those lesser-quality crudes into a high yield of higher-margin products, HollyFrontier has developed an enviable position in the refining space. 

What a Fool believes
Refiners are probably the only companies in the oil and gas space today that are benefiting from the rapid decline in crude prices. However, HollyFrontier's management isn't just resting on its laurels to let the whims of the commodity market determine the success of the company. Through well-timed and well-placed investments in its refining facilities and several logistics assets that source crude to its refineries, HollyFrontier has positioned itself well to continually produce high rates of return in a business that isn't always known for high returns.

Tyler Crowe has no position in any stocks mentioned. You can follow him at Fool.com or on Twitter @TylerCroweFool.

The Motley Fool has no position in any of the stocks mentioned. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.