I also noticed that as you go to sleep the ideas continue, but they become less and less logically interconnected. You don't notice that they're not logically connected until you ask yourself, "What made me think of that?" and you try to work your way back, and often you can't remember what the hell did make you think of that!
Ralph Leighton, Surely You're Joking, Mr. Feynman!: Adventures of a Curious Character
sleeping, thinking