Refactored "virtual machine" code.