cleaner vm implementation under vm.rs, also think it works now