I think you're close, but I notice a common misconception about the brain that everyone seems to make. At least, I think it's a misconception. Thanks to the technological revolution, we tend to associate information storage with the idea of computers. I don't see any reason to think of the brain as a unique internal organ. Every other organ is a bladder of sorts; so is the brain. Perceptions cause nueroelectrical signals that collect in the brain, where they are extracted and used at need. It's information digestion. When you sleep, that information is purged in a series of squirts, each squirt being a dream (non-lucid) - all the unused perceptions being excreted from the system to make room for new perceptions. There are no scripts, programs, databases, hard drives, abstraction layers or integrated circuits. That's just silly. The brain is a bladder. That's my story and I'm stickin' to it!