Refactored and tidied up VMM code.
Refactored and tidied up VMM code.