I've been dealing with some insomnia recently and tried taking melatonin. When I first tried taking it right at my bed time, I found I was wired for a few hours then was able to go to sleep.
When I tried taking it a few hours before my bed time, I found I was unable to go to sleep for like 6 hours.
I've also found codeine has similar effects of making me feel wired.

1) Why does my body turn these products which make everyone else sleepy into a temporary stimulant for me?

2) Among a lot of other changes, I had tried to begin a diet on Saturday, and on Sunday night and Monday night, I felt a terrible sense of hunger(along with the insomnia.) I suppose I should have expected that, but is there any way to get through it other than grinning and bearing it? I actually gave in to my hunger craving Sunday night, and was surprised to find that despite the extra calories, I had lost 5 lbs between Sunday and Monday. I suppose this speaks to the fact that I did in fact need the additional calories?
*Don't worry I'm not trying to lose 5 lbs a day or even a week, in fact I'd like to not do that.

Any help in these matters would be appreciated.