My mind needs to wander to sleep, so it will make up a hole bunch of random scenes in my mind before I eventually fall asleep. Sometimes, it is problem solving.

In fact last night it was problem solving probably because I read this thread I don't remember what the scenarios are right now, all I remember is that about 4 times I snapped out of the trance and thought "Oh yeah I'm trying to sleep."