Fixed error handling. Should work within virtual machine.