Investing can be a difficult and sometimes painful pursuit. For example, earlier this spring I penned a piece explaining why I loved Headwaters (NYSE:HW). At the time, I argued that the company was a solid investment because it was trading for around $20 a share, and with 2007 earnings expected to come in between $1.60-$1.80, it had a price-to-earnings ratio of 11.

Since then, the company's stock has lost 25% of its value -- even though in this past quarter, management boosted its 2007 expected earnings to between $2.35-$2.50 a share. It now has a P/E ratio of less than 7.

So does this mean that I now love Headwaters even more? In a word: absolutely. Here's why.

A market overreaction?
I don't claim to understand the mind of the marketplace, but I figure that investors have soured on Headwaters for two reasons. First, because its coal synfuel business -- which for years was the company's primary source of revenue -- will be adversely affected by the expiration at the end of this year of Section 45 of the U.S. tax code. As a result, coal producers will no longer receive a tax credit for producing synthetic fuel from coal.

The second potential reason for the price decline is because growth is slowing in the construction industry. This caused revenues from Headwaters' construction materials division to drop $6.5 million from the previous year's quarter.

At first glance, the two issues offer legitimate cause for concern, but in both instances, I believe the market overreacted. Headwaters has been planning for the expiration of the Section 45 tax credit for years, and it's done a solid job of diversifying its business away from its former reliance on synfuel. Secondly, in spite of the phase-out of the tax credit and high oil prices (which trigger a reduction in the tax credit), synfuel producers have still been purchasing Headwaters' chemical reagents.

As to the reduction of revenue from its construction material division, again, this isn't a positive development. Still, it's hard to argue that a 4% reduction in quarterly sales (from $162 million to $156 million) is much cause for concern -- especially when the company's other divisions more than made up for the slack by driving up total revenue more than $40 million -- or 14% -- in the past quarter.

An even closer review of its construction material business offers another reason to believe that the division will soon return to positive growth. At the present time, the type of fly ash concrete that Headwaters helps manufacture makes up only 11% of the U.S. market for concrete. However, as fly ash's advantages of strength, durability, and resistance to corrosion become better known in the construction industry, this number should increase and provide the company with a solid platform to build upon. Given that large Portland cement users such as Cemex (NYSE:CX) and Lafarge (NYSE:LR) both sport a P/E ratio of 11.5, this portion of Headwater's business would appear to be trading a substantial discount.

Picking up energy
Its construction material division is not the only aspect of its business that appears undervalued. The company's Energy Services Division also appears to offer a bargain. In particular, three areas appear ripe for growth. For starters, the company now operates (in partnership with Great River Energy) a 50-million-gallon ethanol facility which has the capacity to expand to 65 million gallons.

Second, the business is now generating revenue from cleaning waste coal. There are an estimated 5 billion tons of waste coal still in the ground in this country, and Headwaters has yet to scratch the surface of this vast market opportunity.

The third area the company is poised to benefit from is from coal drying. Coal from the western parts of the United States and Canada contains more water than Eastern coal, thus requiring coal companies to expend more energy (and money) drying it. Headwaters is now commercializing a new technology that not only increases burning efficiency by up to 15%, but also helps reduce mercury, sulfur, and nitrogen oxide emissions of the coal it dries. With the demand for Western coal expected to increase, and with tighter environmental restriction likely in the years ahead, this portion of the business could also grow.

A tiny catalyst
Finally, I continue to believe that the market isn't placing any value on Headwaters Technology Innovation Group, which is seeking to perfect a variety of new nanocatalysts. Perhaps this is as it should be, because this division isn't yet producing any meaningful revenue for the company. From my perspective, though, if even one of its nanocatalysts works as promised, the result could be a massive windfall for the company and its investors.

For instance, one catalyst currently under development might transform low-grade gas into higher-octane fuel. With a price differential of $0.20 per gallon between higher- and lower-octane fuel, and with more than 50 million gallons of premium gas sold a day, a strong financial incentive exists for oil companies such as ExxonMobil (NYSE:XOM), BP (NYSE:BP) and ConocoPhillips (NYSE:COP) to actively explore Headwaters' nanocatalyst technology.

An even bigger opportunity lies in the fields of upgrading heavy, bottom-of-the-barrel oil into lighter crude. Here the difference between a barrel of heavy oil and lighter oil is about $20, and the potential market opportunity for Headwaters is billions of dollars.

Making headway
To reiterate, although none of its nanocatalyst technologies has yet yielded a commercial breakthrough, they remain under active consideration by a handful of undisclosed oil and refining companies. As such, the technology would seem to hold at least some potential value. However, even if it isn't worth a penny, I am of the opinion that Headwaters' other two divisions -- which are generating better-than-expected profits -- are undervalued. Eventually, investors will come to understand that the sum total of Headwaters various parts exceeds its present value. As such, I am even more confident that the company represents an even more extraordinary value than when I first recommended it back in February.

Interested in reading more about Headwaters? Check out these articles:

Fool contributor Jack Uldrich owns stock in Headwaters. Headwaters is a Motley Fool Rule Breakers recommendation. Cemex has been chosen by both Stock Advisor and Global Gains. The Fool has a strict disclosure policy.