Having had the same or very similar problems with my CMG in most cases a good cleaning like the others have mentioned will usually fix the problem.
But along with cleaning the contacts some times gunk and lint from your pocket will pack into the rim between the body and the head. Since you open this gap to turn the light off if it gets filled up it can keep you from tightening the lid down far enough to make contact. But turning it off and on can disturb this build up to be refilled later in your pocket. This will often cause eradic operation. So if it doesn't want to light try loosening the head and run a thumbnail through the gap.
As a last resort some of the early models were a bit to long or the threads were not deep enough for the battery to make good contact. Even with the head screwed down all the way it was iffy at best weather it would work. Some times you get a battery that is just a hair longer that works great. The reverse of the dimpling problem mentioned. If this is the case you need to shorten the distance. Since you can't actually shorten the case you need to do the next best thing. Cut a disc of aluminum foil the size of the inside of the case. Drop it into the bottom and stick in the battery. Even the thin sheet of foil should give you the extra distance needed. The sheet will wear and need to be replaced. By normally only when changing the battery.
_________________________
When in danger or in doubt
run in circles scream and shout
RAH
And always remember TANSTAAFL