what's the deal with morning wood?

What’s the deal with “morning wood”? My psychology of human sexuality teacher said that erections are not uncommon in males during REM sleep and so if a male is woken up during REM sleep, he may still have an erection. I disagree with this explanation. I think that it has something to do with the blood flow in your body when you come out of sleep. I also think it might have to do with the position of your body in relation to your blood flow. I might be going into too much detail here, but speaking from personal experience, if I have an erection when I wake up and I sit up, it goes away. Then if I lie down again, it comes back. Okay, sorry you had to read that, but anyways, can anyone explain morning wood?