I know allok, maybe I don't
The point is that during the day everything get's stuffed into your short term memory and when you go to sleep your brain moves it all to the long term memory. First it needs to analize all your memorys to find a fitting place (this is a cause of dreaming) and your brain also does a diagnostic on your body and brain during your sleep, this can be a cause of dreaming. We don't know the brain that well yet but I'm pretty certain it's one of the 2 above.