With a refining operation as large as Valero Energy's (NYSE:VLO), even the slightest uptick in the refining market can have a noticeable effect on the bottom line. Thanks to slightly better margins and a low maintenance period for its refineries, Valero was able to exceed expectations for the second quarter. 

What is even more promising, though, is that management expects the market to improve even more from here. Let's take a look at Valero's most recent quarterly earnings and see what management thinks will drive better results in the near future.

Oil refinery

Image source: Getty Images.

By the numbers

Metric Q2 2017 Q1 2017 Q2 2016
Revenue $22,254 million $21,772 million $19,584 million
Operating income $871 million $537 million $1,231 million
EPS $1.23 $0.68 $1.74
Free cash flow $1,336 million $988 million $1,858 million

Data source: Valero earnings releases.

Second-quarter earnings improved slightly for Valero thanks to a modestly better refining market and improved operations. Throughput margins for a barrel of crude oil jumped $0.52 per barrel to $8.66 compared to the prior quarter, which helped bump per-barrel operating income from $2.53 to $3.49. On the operating side, Valero did a lot of maintenance and turnaround work in the prior quarter that lowered utilization rates to 91%. In the second quarter, utilization was back up to 96%.

Even though management now breaks out its earnings in three new segments -- Refining, Ethanol, and Valero Energy Partners (NYSE:VLP) -- it's pretty clear that refining is the one that matters when it comes to quarterly earnings. Ethanol did suffer a bit from pricing pressure, and Valero Energy Partners' results benefited from a couple of drop-down assets. Those two are just on the margins for Valero's overall profitability, though. 

VLO operating income by business segment. Shows that Refining is multiples larger than its other two businesses

Data source: Valero Energy earnings releases. Chart by author.

For reigning in general, one of the largest costs hitting the bottom line is the compliance costs for the Renewable Fuel Standard. Valero spent $255 million in the quarter for renewable identification number (RIN) credits to meet its ethanol blending obligation. Management estimates RIN costs will be around $750 million for the year. 

Similar to the prior quarter, the company's strongest refining region continues to be the U.S. Gulf Coast. This region has the benefit of a robust petroleum product export business, which isn't subject to RIN compliance. Valero's exports for the quarter were 369,000 barrels per day. However, increased uptime in the Mid-continent and North Atlantic regions boosted profits. 

VLO adjusted operating income by refining region for Q2 2016, Q1 2017, and Q2 2017.Shows gains across the board compared to prior quarter

 *ADJUSTED OPERATING INCOME IS DEFINED AS OPERATING INCOME EXCLUDING LOWER OF COST OR MARKET INVENTORY VALUATION ADJUSTMENT AND ASSET IMPAIRMENT LOSS. Data source: Valero Energy earnings release. Chart by author.

Valero generated $1.8 billion in cash from operations in the quarter, $461 of which was used on capital expenditures. Management used the rest to pay dividends and buy back $346 million in stock, which is in line with Valero's target to return 75% of net income through dividends and share repurchases. With the cash left over, the company now has $5.2 billion in cash and $2.0 billion in net debt.

What management had to say

Here's CEO Greg Gorder on what Valero's management team is seeing in the refining market today.

[W]e're pleased to see a rebound in distillate demand, in addition to the strong gasoline pull by domestic and export customers. Downward trends and product inventories and structural shortages in the primary export markets for the U.S. Gulf Coast provide an encouraging backdrop as we move into the second half of the year. On the crude supply side, we're seeing the impact of the OPEC cuts on the medium and heavy sour discounts, but increased U.S. drilling activity and crude production have supported attractive domestic sweet crude discounts relative to Brent in the second quarter. As a result, we switched our refining system to a maximum light crude slate in June.

What a Fool believes

The refining market still isn't in great shape, but Valero is managing the downturn rather well with low-cost operations and significant cash flow. If Gorder's outlook on refined products is correct, we might see a bump in refining margins in the coming quarters. Over the long term, though, investor focus should be on efficient operations and control costs from its refining business, and some modest growth from its logistics partnership. So far, Valero has delivered on those things, and there isn't much reason to that will change anytime soon.

Tyler Crowe has no position in any stocks mentioned. The Motley Fool has no position in any of the stocks mentioned. The Motley Fool has a disclosure policy.