I don't really know about the scientific side of things like the sleep cycles, but I would certainly agree that it sounds like you had a lucid dream. Try looking up the Wake Back To Bed (WBTB) technique, that might help you with your answers and for future dreams. Good luck