I have sleep problems at night, always go to bed early, but keep awake till midnight? sometime i got nightmares. I guess maybe there are some kinda iPhone APP can make some effect, and make me sleep well.
If you have nightmares a lot, perhaps you are too warm at night. Try sleeping with the window open or make your room cooler somehow.
Waking up in the middle of the night is also pretty normal historically (humans as it appears probably aren't meant to have 8 hours of constant sleep), and the fact you wake up in the middle of the night is probably making you anxious, thus making it harder to get back to sleep.