Fix some bugs in the VM, add comments