Insomnia is a slight withdrawl symptom from marijuana. (I'm haven that problem now) Usually takes up to a week of not smoking for sleep patterns to re-establish. Marijuana does indeed effect melatonin levels.

Insomnia WHILE smoking? Hmmmmmmm

If you've been smoking heavily your melatonin levels might be a little off base.
Also, certain strains (strong sativas) can actually make you energetic.

Strong indicas are what you want to use before bed.

Try some White Rhino.....you'll pass out before you even finish it. lol