I have a gas 40 Gal AO SMith hot water heater that is 9 years old. There are times when it produces hot water with no problems. Then there are other times when the water is luke warm even when hot water hasn't been used for some time. It is not related to the shower valve because if it isn't hot enough in the shower, it won't be hot enough out of any other tap. Does this sound like a thermostat issue? It doesn't happen all the time only occasionally. Is it worth trying to replace the thermostat or just buy a new hot water heater?