I have this theory that dreams are the experience of our brains rebooting after being taken down for maintenance; kind of like reading from uninitialized memory.
Dreams are maintenance. They are overnight batch processing after the realtime system is largely shut down. Your realtime conscious system then reboots from the now consolidated memory when you wake up.
You are a new and different person each morning.