Refining giant Valero Energy Corporation (VLO -0.98%) recently reported strong second-quarter results. The company was easily able to overcome weakness in its ethanol segment, as its refining margin widened. Here are three important takeaways from its second-quarter results.

1. It loves the current market environment
For the second quarter, Valero reported $1.4 billion in net income from operations, or $2.66 per share. Not only was that well above the $651 million, or $1.22 per share it reported in the year-ago quarter, but its earnings beat the analysts' consensus estimate by $0.24 per share.

Fueling the surge was the company's refining segment, which reported $2.2 billion in operating income. That was double what the segment reported in the year-ago period. Further, it more than offset weakness from its ethanol segment, as that segment's operating income fell from $187 million in the year-ago quarter to just $108 million this quarter.

The refining segment's results were driven by weaker oil prices, which not only reduced feedstock costs, but spurred consumer demand for Valero's refined petroleum products. This pushed the company's throughput margin per barrel up by $3.87 year over year, to $13.71 per barrel. Also driving the refining segment's strength were stronger volumes, as its throughput volumes averaged 2.8 million barrels per day, which was 87,000 barrels per day higher than the year-ago quarter.

2. It's gushing cash flow and returning it to shareholders
As a result of the company's robust refining operations, Valero is generating a lot of cash flow these days. That's really great news for shareholders, as the company's current plan is to return 75% of its net income back to them each year. Currently, the company is spreading the wealth, so to speak, between dividends and share repurchases.

Last quarter, the company returned a total of $870 million to investors, sending $203 million back via dividends, while also buying back $667 million in stock. During the past six months, the pace of share repurchases has doubled as a result of its strong results.

Meanwhile, additional stock repurchases are on the way after the company bolstered its stock buyback authorization by $2.5 billion recently. When combined with what's left on its previous authorization, it gives the company the ability to repurchase $2.9 billion in stock, or just less than 10% of total shares outstanding at the current stock prices.

3. More growth in the pipeline
Valero is also using its strong cash flow to fund projects that will drive future cash-flow growth, as it plans to spend $1.15 billion this year on growth investments. These investments are intended to enhance the company's ability to access and process cheaper North American crude oil, which should improve refining margins.

However, the company is also exploring the potential to build two additional refining growth investments that would process low-cost natural gas, or NGLs, into higher-value products. These projects include the St. Charles methanol and Houston alkylation projects. Both projects would be a slight deviation from the company's current crude-focused business; but given the abundance of cheap natural gas in the country, it's a move that makes a lot of sense. 

Investor takeaway
Valero's second-quarter results were really good, as it benefits from lower oil prices. As a result, the company is just gushing with cash flow right now, which it's returning to shareholders, and using to build projects that will drive future growth. It's in a good spot right now, to say the least.