Moved stack code out of vm.py