Nightmares in response to melatonin suggests low serotonin. Try 5-HTP sometime, which is a partial prodrug for melatonin and in practice works quite similarly to melatonin, except it induces vivid happy dreams and is the proscribed treatment for night terrors in children.