Image: Valmont Industries.

Thursday reversed some of the stock market's gains from earlier in the week as investors took a closer look at the big gains over the past couple of months, and reconciled them with what they've seen so far during the first-quarter earnings season. Overall, weakness in energy and commodities helped to hold back the market from further gains, and major market benchmarks finished the day down about half a percent.

Yet many stocks still managed to post substantial gains. Among the best performers were Viacom (VIAB), Crestwood Equity Partners (CEQP), and Valmont Industries (VMI -0.69%).

Viacom jumped 14%, reversing losses from earlier in the week after the media giant found a way to renegotiate terms of its deal with DISH Network to prevent a potential blackout. The two parties managed to make a multi-year renewal agreement under which DISH subscribers will continue to have access to all 18 of the networks that Viacom offers.

Exact terms of the agreement weren't released, but many had feared that DISH would hold out to make a more extensive adjustment of the terms under which it accepted programming from Viacom and other content providers. Given how many times companies in similar situations have reached last-minute deals, it's somewhat surprising that the stock was as volatile as it was; but because it dropped on fears of no deal occurring, it made sense that Viacom would rise on positive news.

Crestwood Equity Partners soared 42% in the wake of its announcement that the natural-gas storage-and-pipeline company had entered into a strategic joint venture with utility company Consolidated Edison. The deal will provide Crestwood with $975 million in cash that it intends to use to reduce its debt. Crestwood also said that it would cut its distribution for the first quarter by more than half to $0.60 per unit, but it intends to use that financial flexibility to pay down debt further, or to reinvest its operating cash flow in profit-making opportunities.

Even with the payout reduction, Crestwood still yields more than 13%, and investors probably feared a more-extensive cut that might have resulted in their getting no distributions at all. Given how essential it has been for energy companies to have liquidity lately, the deal gives Crestwood capital access at a critical time.

Finally, Valmont Industries gained 12%. The irrigation and infrastructure product specialist released its first-quarter results late Wednesday afternoon, and the company managed to boost its earnings despite a double-digit percentage drop in revenue. Valmont pointed to its cost-containment efforts as instrumental in helping it produce bottom-line growth, praising not only its business restructuring, but also broader-based productivity improvements in helping it squeeze more profit from lower sales.

Despite operating in a challenging business environment, the company believes that "the positive long-term global drivers of our businesses remain in place." With Valmont behaving this well even when its core industry is in the throes of a massive cyclical downturn, investors hope that the company will bounce back sharply when times get better.