Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 55233)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp	(revision 55234)
@@ -650,7 +650,7 @@
             do
             {
-                ComPtr<IMachine> console;
-                CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(machine.asOutParam()));
-                CHECK_ERROR_BREAK(console, DiscardSavedState(true /* fDeleteFile */));
+                ComPtr<IMachine> sessionMachine;
+                CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, DiscardSavedState(true /* fDeleteFile */));
             } while (0);
             CHECK_ERROR_BREAK(a->session, UnlockMachine());
@@ -687,7 +687,7 @@
             do
             {
-                ComPtr<IMachine> machine;
-                CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(machine.asOutParam()));
-                CHECK_ERROR_BREAK(machine, AdoptSavedState(Bstr(szStateFileAbs).raw()));
+                ComPtr<IMachine> sessionMachine;
+                CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, AdoptSavedState(Bstr(szStateFileAbs).raw()));
             } while (0);
             CHECK_ERROR_BREAK(a->session, UnlockMachine());
@@ -807,12 +807,13 @@
             CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Shared), 1);
             /* get the session machine */
-            CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);
+            ComPtr<IMachine> sessionMachine;
+            CHECK_ERROR_RET(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()), 1);
             /** @todo passing NULL is deprecated */
             if (a->argc < 3)
-                CHECK_ERROR(machine, SetExtraData(Bstr(a->argv[1]).raw(),
-                                                  NULL));
+                CHECK_ERROR(sessionMachine, SetExtraData(Bstr(a->argv[1]).raw(),
+                                                         NULL));
             else if (a->argc == 3)
-                CHECK_ERROR(machine, SetExtraData(Bstr(a->argv[1]).raw(),
-                                                  Bstr(a->argv[2]).raw()));
+                CHECK_ERROR(sessionMachine, SetExtraData(Bstr(a->argv[1]).raw(),
+                                                         Bstr(a->argv[2]).raw()));
             else
                 return errorSyntax(USAGE_SETEXTRADATA, "Too many parameters");
@@ -989,6 +990,9 @@
             /* open an existing session for the VM */
             CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Shared), 1);
+
             /* get the session machine */
-            CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);
+            ComPtr<IMachine> sessionMachine;
+            CHECK_ERROR_RET(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()), 1);
+
             /* get the session console */
             CHECK_ERROR_RET(a->session, COMGETTER(Console)(console.asOutParam()), 1);
@@ -1006,11 +1010,12 @@
 
             /* get the mutable session machine */
-            a->session->COMGETTER(Machine)(machine.asOutParam());
-
-            CHECK_ERROR(machine, CreateSharedFolder(Bstr(name).raw(),
-                                                    Bstr(hostpath).raw(),
-                                                    fWritable, fAutoMount));
+            ComPtr<IMachine> sessionMachine;
+            a->session->COMGETTER(Machine)(sessionMachine.asOutParam());
+
+            CHECK_ERROR(sessionMachine, CreateSharedFolder(Bstr(name).raw(),
+                                                           Bstr(hostpath).raw(),
+                                                           fWritable, fAutoMount));
             if (SUCCEEDED(rc))
-                CHECK_ERROR(machine, SaveSettings());
+                CHECK_ERROR(sessionMachine, SaveSettings());
 
             a->session->UnlockMachine();
@@ -1056,5 +1061,6 @@
             CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Shared), 1);
             /* get the session machine */
-            CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);
+            ComPtr<IMachine> sessionMachine;
+            CHECK_ERROR_RET(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()), 1);
             /* get the session console */
             CHECK_ERROR_RET(a->session, COMGETTER(Console)(console.asOutParam()), 1);
@@ -1071,10 +1077,11 @@
 
             /* get the mutable session machine */
-            a->session->COMGETTER(Machine)(machine.asOutParam());
-
-            CHECK_ERROR(machine, RemoveSharedFolder(Bstr(name).raw()));
+            ComPtr<IMachine> sessionMachine;
+            a->session->COMGETTER(Machine)(sessionMachine.asOutParam());
+
+            CHECK_ERROR(sessionMachine, RemoveSharedFolder(Bstr(name).raw()));
 
             /* commit and close the session */
-            CHECK_ERROR(machine, SaveSettings());
+            CHECK_ERROR(sessionMachine, SaveSettings());
             a->session->UnlockMachine();
         }
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp	(revision 55233)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp	(revision 55234)
@@ -460,8 +460,4 @@
     HRESULT rc;
     Bstr name;
-    RTGETOPTUNION ValueUnion;
-    RTGETOPTSTATE GetOptState;
-    ComPtr<IMachine> machine;
-    ComPtr<IBIOSSettings> biosSettings;
 
     /* VM ID + at least one parameter. Parameter arguments are checked
@@ -470,5 +466,6 @@
         return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");
 
-    /* try to find the given machine */
+    /* try to find the given sessionMachine */
+    ComPtr<IMachine> machine;
     CHECK_ERROR_RET(a->virtualBox, FindMachine(Bstr(a->argv[0]).raw(),
                                                machine.asOutParam()), 1);
@@ -481,11 +478,16 @@
     CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Write), 1);
 
-    /* get the mutable session machine */
-    CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);
-    machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
-
+    /* get the mutable session sessionMachine */
+    ComPtr<IMachine> sessionMachine;
+    CHECK_ERROR_RET(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()), 1);
+
+    ComPtr<IBIOSSettings> biosSettings;
+    sessionMachine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
+
+    RTGETOPTSTATE GetOptState;
     RTGetOptInit(&GetOptState, a->argc, a->argv, g_aModifyVMOptions,
                  RT_ELEMENTS(g_aModifyVMOptions), 1, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
 
+    RTGETOPTUNION ValueUnion;
     while (   SUCCEEDED (rc)
            && (c = RTGetOpt(&GetOptState, &ValueUnion)))
@@ -495,5 +497,5 @@
             case MODIFYVM_NAME:
             {
-                CHECK_ERROR(machine, COMSETTER(Name)(Bstr(ValueUnion.psz).raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(Name)(Bstr(ValueUnion.psz).raw()));
                 break;
             }
@@ -502,10 +504,10 @@
                 com::SafeArray<BSTR> groups;
                 parseGroups(ValueUnion.psz, &groups);
-                CHECK_ERROR(machine, COMSETTER(Groups)(ComSafeArrayAsInParam(groups)));
+                CHECK_ERROR(sessionMachine, COMSETTER(Groups)(ComSafeArrayAsInParam(groups)));
                 break;
             }
             case MODIFYVM_DESCRIPTION:
             {
-                CHECK_ERROR(machine, COMSETTER(Description)(Bstr(ValueUnion.psz).raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(Description)(Bstr(ValueUnion.psz).raw()));
                 break;
             }
@@ -517,5 +519,5 @@
                 if (SUCCEEDED(rc) && guestOSType)
                 {
-                    CHECK_ERROR(machine, COMSETTER(OSTypeId)(Bstr(ValueUnion.psz).raw()));
+                    CHECK_ERROR(sessionMachine, COMSETTER(OSTypeId)(Bstr(ValueUnion.psz).raw()));
                 }
                 else
@@ -560,5 +562,5 @@
                 }
                 RTFileClose(iconFile);
-                CHECK_ERROR(machine, COMSETTER(Icon)(ComSafeArrayAsInParam(icon)));
+                CHECK_ERROR(sessionMachine, COMSETTER(Icon)(ComSafeArrayAsInParam(icon)));
                 break;
             }
@@ -566,5 +568,5 @@
             case MODIFYVM_MEMORY:
             {
-                CHECK_ERROR(machine, COMSETTER(MemorySize)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(MemorySize)(ValueUnion.u32));
                 break;
             }
@@ -572,5 +574,5 @@
             case MODIFYVM_PAGEFUSION:
             {
-                CHECK_ERROR(machine, COMSETTER(PageFusionEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(PageFusionEnabled)(ValueUnion.f));
                 break;
             }
@@ -578,5 +580,5 @@
             case MODIFYVM_VRAM:
             {
-                CHECK_ERROR(machine, COMSETTER(VRAMSize)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(VRAMSize)(ValueUnion.u32));
                 break;
             }
@@ -586,21 +588,21 @@
                 if (!RTStrICmp(ValueUnion.psz, "efi"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI));
+                    CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_EFI));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "efi32"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI32));
+                    CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_EFI32));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "efi64"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFI64));
+                    CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_EFI64));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "efidual"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_EFIDUAL));
+                    CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_EFIDUAL));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "bios"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(FirmwareType)(FirmwareType_BIOS));
+                    CHECK_ERROR(sessionMachine, COMSETTER(FirmwareType)(FirmwareType_BIOS));
                 }
                 else
@@ -626,5 +628,5 @@
             case MODIFYVM_PAE:
             {
-                CHECK_ERROR(machine, SetCPUProperty(CPUPropertyType_PAE, ValueUnion.f));
+                CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_PAE, ValueUnion.f));
                 break;
             }
@@ -632,5 +634,5 @@
             case MODIFYVM_LONGMODE:
             {
-                CHECK_ERROR(machine, SetCPUProperty(CPUPropertyType_LongMode, ValueUnion.f));
+                CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_LongMode, ValueUnion.f));
                 break;
             }
@@ -638,5 +640,5 @@
             case MODIFYVM_SYNTHCPU:
             {
-                CHECK_ERROR(machine, SetCPUProperty(CPUPropertyType_Synthetic, ValueUnion.f));
+                CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_Synthetic, ValueUnion.f));
                 break;
             }
@@ -644,5 +646,5 @@
             case MODIFYVM_TFRESET:
             {
-                CHECK_ERROR(machine, SetCPUProperty(CPUPropertyType_TripleFaultReset, ValueUnion.f));
+                CHECK_ERROR(sessionMachine, SetCPUProperty(CPUPropertyType_TripleFaultReset, ValueUnion.f));
                 break;
             }
@@ -652,15 +654,15 @@
                 if (   !RTStrICmp(ValueUnion.psz, "none")
                     || !RTStrICmp(ValueUnion.psz, "disabled"))
-                    CHECK_ERROR(machine, COMSETTER(ParavirtProvider)(ParavirtProvider_None));
+                    CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_None));
                 else if (!RTStrICmp(ValueUnion.psz, "default"))
-                    CHECK_ERROR(machine, COMSETTER(ParavirtProvider)(ParavirtProvider_Default));
+                    CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_Default));
                 else if (!RTStrICmp(ValueUnion.psz, "legacy"))
-                    CHECK_ERROR(machine, COMSETTER(ParavirtProvider)(ParavirtProvider_Legacy));
+                    CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_Legacy));
                 else if (!RTStrICmp(ValueUnion.psz, "minimal"))
-                    CHECK_ERROR(machine, COMSETTER(ParavirtProvider)(ParavirtProvider_Minimal));
+                    CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_Minimal));
                 else if (!RTStrICmp(ValueUnion.psz, "hyperv"))
-                    CHECK_ERROR(machine, COMSETTER(ParavirtProvider)(ParavirtProvider_HyperV));
+                    CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_HyperV));
                 else if (!RTStrICmp(ValueUnion.psz, "kvm"))
-                    CHECK_ERROR(machine, COMSETTER(ParavirtProvider)(ParavirtProvider_KVM));
+                    CHECK_ERROR(sessionMachine, COMSETTER(ParavirtProvider)(ParavirtProvider_KVM));
                 else
                 {
@@ -673,5 +675,5 @@
             case MODIFYVM_HWVIRTEX:
             {
-                CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_Enabled, ValueUnion.f));
+                CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_Enabled, ValueUnion.f));
                 break;
             }
@@ -691,5 +693,5 @@
                     aValue[i] = ValueUnion.u32;
                 }
-                CHECK_ERROR(machine, SetCPUIDLeaf(id, aValue[0], aValue[1], aValue[2], aValue[3]));
+                CHECK_ERROR(sessionMachine, SetCPUIDLeaf(id, aValue[0], aValue[1], aValue[2], aValue[3]));
                 break;
             }
@@ -697,5 +699,5 @@
             case MODIFYVM_DELCPUID:
             {
-                CHECK_ERROR(machine, RemoveCPUIDLeaf(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, RemoveCPUIDLeaf(ValueUnion.u32));
                 break;
             }
@@ -703,5 +705,5 @@
             case MODIFYVM_DELALLCPUID:
             {
-                CHECK_ERROR(machine, RemoveAllCPUIDLeaves());
+                CHECK_ERROR(sessionMachine, RemoveAllCPUIDLeaves());
                 break;
             }
@@ -709,5 +711,5 @@
             case MODIFYVM_NESTEDPAGING:
             {
-                CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, ValueUnion.f));
+                CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_NestedPaging, ValueUnion.f));
                 break;
             }
@@ -715,5 +717,5 @@
             case MODIFYVM_LARGEPAGES:
             {
-                CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_LargePages, ValueUnion.f));
+                CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_LargePages, ValueUnion.f));
                 break;
             }
@@ -721,5 +723,5 @@
             case MODIFYVM_VTXVPID:
             {
-                CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_VPID, ValueUnion.f));
+                CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_VPID, ValueUnion.f));
                 break;
             }
@@ -727,5 +729,5 @@
             case MODIFYVM_VTXUX:
             {
-                CHECK_ERROR(machine, SetHWVirtExProperty(HWVirtExPropertyType_UnrestrictedExecution, ValueUnion.f));
+                CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_UnrestrictedExecution, ValueUnion.f));
                 break;
             }
@@ -733,5 +735,5 @@
             case MODIFYVM_CPUS:
             {
-                CHECK_ERROR(machine, COMSETTER(CPUCount)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(CPUCount)(ValueUnion.u32));
                 break;
             }
@@ -739,5 +741,5 @@
             case MODIFYVM_RTCUSEUTC:
             {
-                CHECK_ERROR(machine, COMSETTER(RTCUseUTC)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(RTCUseUTC)(ValueUnion.f));
                 break;
             }
@@ -745,5 +747,5 @@
             case MODIFYVM_CPUHOTPLUG:
             {
-                CHECK_ERROR(machine, COMSETTER(CPUHotPlugEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(CPUHotPlugEnabled)(ValueUnion.f));
                 break;
             }
@@ -751,5 +753,5 @@
             case MODIFYVM_PLUGCPU:
             {
-                CHECK_ERROR(machine, HotPlugCPU(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, HotPlugCPU(ValueUnion.u32));
                 break;
             }
@@ -757,5 +759,5 @@
             case MODIFYVM_UNPLUGCPU:
             {
-                CHECK_ERROR(machine, HotUnplugCPU(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, HotUnplugCPU(ValueUnion.u32));
                 break;
             }
@@ -763,5 +765,5 @@
             case MODIFYVM_CPU_EXECTUION_CAP:
             {
-                CHECK_ERROR(machine, COMSETTER(CPUExecutionCap)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(CPUExecutionCap)(ValueUnion.u32));
                 break;
             }
@@ -771,14 +773,14 @@
                 if (   !RTStrICmp(ValueUnion.psz, "none")
                     || !RTStrICmp(ValueUnion.psz, "disabled"))
-                    CHECK_ERROR(machine, COMSETTER(GraphicsControllerType)(GraphicsControllerType_Null));
+                    CHECK_ERROR(sessionMachine, COMSETTER(GraphicsControllerType)(GraphicsControllerType_Null));
                 else if (   !RTStrICmp(ValueUnion.psz, "vboxvga")
                          || !RTStrICmp(ValueUnion.psz, "vbox")
                          || !RTStrICmp(ValueUnion.psz, "vga")
                          || !RTStrICmp(ValueUnion.psz, "vesa"))
-                    CHECK_ERROR(machine, COMSETTER(GraphicsControllerType)(GraphicsControllerType_VBoxVGA));
+                    CHECK_ERROR(sessionMachine, COMSETTER(GraphicsControllerType)(GraphicsControllerType_VBoxVGA));
 #ifdef VBOX_WITH_VMSVGA
                 else if (   !RTStrICmp(ValueUnion.psz, "vmsvga")
                          || !RTStrICmp(ValueUnion.psz, "vmware"))
-                    CHECK_ERROR(machine, COMSETTER(GraphicsControllerType)(GraphicsControllerType_VMSVGA));
+                    CHECK_ERROR(sessionMachine, COMSETTER(GraphicsControllerType)(GraphicsControllerType_VMSVGA));
 #endif
                 else
@@ -792,5 +794,5 @@
             case MODIFYVM_MONITORCOUNT:
             {
-                CHECK_ERROR(machine, COMSETTER(MonitorCount)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(MonitorCount)(ValueUnion.u32));
                 break;
             }
@@ -798,5 +800,5 @@
             case MODIFYVM_ACCELERATE3D:
             {
-                CHECK_ERROR(machine, COMSETTER(Accelerate3DEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(Accelerate3DEnabled)(ValueUnion.f));
                 break;
             }
@@ -805,5 +807,5 @@
             case MODIFYVM_ACCELERATE2DVIDEO:
             {
-                CHECK_ERROR(machine, COMSETTER(Accelerate2DVideoEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(Accelerate2DVideoEnabled)(ValueUnion.f));
                 break;
             }
@@ -872,21 +874,21 @@
                 if (!RTStrICmp(ValueUnion.psz, "none"))
                 {
-                    CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_Null));
+                    CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_Null));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "floppy"))
                 {
-                    CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_Floppy));
+                    CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_Floppy));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "dvd"))
                 {
-                    CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_DVD));
+                    CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_DVD));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "disk"))
                 {
-                    CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_HardDisk));
+                    CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_HardDisk));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "net"))
                 {
-                    CHECK_ERROR(machine, SetBootOrder(GetOptState.uIndex, DeviceType_Network));
+                    CHECK_ERROR(sessionMachine, SetBootOrder(GetOptState.uIndex, DeviceType_Network));
                 }
                 else
@@ -927,5 +929,5 @@
                 if (!RTStrICmp(ValueUnion.psz, "none"))
                 {
-                    machine->DetachDevice(bstrController.raw(), u1, u2);
+                    sessionMachine->DetachDevice(bstrController.raw(), u1, u2);
                 }
                 else
@@ -940,5 +942,5 @@
                     if (hardDisk)
                     {
-                        CHECK_ERROR(machine, AttachDevice(bstrController.raw(),
+                        CHECK_ERROR(sessionMachine, AttachDevice(bstrController.raw(),
                                                           u1, u2,
                                                           DeviceType_HardDisk,
@@ -954,5 +956,5 @@
             {
                 ComPtr<IStorageController> storageController;
-                CHECK_ERROR(machine, GetStorageControllerByName(Bstr("IDE Controller").raw(),
+                CHECK_ERROR(sessionMachine, GetStorageControllerByName(Bstr("IDE Controller").raw(),
                                                                  storageController.asOutParam()));
 
@@ -980,5 +982,5 @@
             {
                 ComPtr<IStorageController> SataCtl;
-                CHECK_ERROR(machine, GetStorageControllerByName(Bstr("SATA").raw(),
+                CHECK_ERROR(sessionMachine, GetStorageControllerByName(Bstr("SATA").raw(),
                                                                 SataCtl.asOutParam()));
 
@@ -993,5 +995,5 @@
                 {
                     ComPtr<IStorageController> ctl;
-                    CHECK_ERROR(machine, AddStorageController(Bstr("SATA").raw(),
+                    CHECK_ERROR(sessionMachine, AddStorageController(Bstr("SATA").raw(),
                                                               StorageBus_SATA,
                                                               ctl.asOutParam()));
@@ -999,5 +1001,5 @@
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
-                    CHECK_ERROR(machine, RemoveStorageController(Bstr("SATA").raw()));
+                    CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("SATA").raw()));
                 else
                     return errorArgument("Invalid --usb argument '%s'", ValueUnion.psz);
@@ -1009,8 +1011,8 @@
                 if (!RTStrICmp(ValueUnion.psz, "none"))
                 {
-                    rc = machine->DetachDevice(Bstr("LsiLogic").raw(),
+                    rc = sessionMachine->DetachDevice(Bstr("LsiLogic").raw(),
                                                GetOptState.uIndex, 0);
                     if (FAILED(rc))
-                        CHECK_ERROR(machine, DetachDevice(Bstr("BusLogic").raw(),
+                        CHECK_ERROR(sessionMachine, DetachDevice(Bstr("BusLogic").raw(),
                                                           GetOptState.uIndex, 0));
                 }
@@ -1026,10 +1028,10 @@
                     if (hardDisk)
                     {
-                        rc = machine->AttachDevice(Bstr("LsiLogic").raw(),
+                        rc = sessionMachine->AttachDevice(Bstr("LsiLogic").raw(),
                                                    GetOptState.uIndex, 0,
                                                    DeviceType_HardDisk,
                                                    hardDisk);
                         if (FAILED(rc))
-                            CHECK_ERROR(machine,
+                            CHECK_ERROR(sessionMachine,
                                         AttachDevice(Bstr("BusLogic").raw(),
                                                      GetOptState.uIndex, 0,
@@ -1049,9 +1051,9 @@
                 if (!RTStrICmp(ValueUnion.psz, "LsiLogic"))
                 {
-                    rc = machine->RemoveStorageController(Bstr("BusLogic").raw());
+                    rc = sessionMachine->RemoveStorageController(Bstr("BusLogic").raw());
                     if (FAILED(rc))
-                        CHECK_ERROR(machine, RemoveStorageController(Bstr("LsiLogic").raw()));
-
-                    CHECK_ERROR(machine,
+                        CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("LsiLogic").raw()));
+
+                    CHECK_ERROR(sessionMachine,
                                  AddStorageController(Bstr("LsiLogic").raw(),
                                                       StorageBus_SCSI,
@@ -1063,9 +1065,9 @@
                 else if (!RTStrICmp(ValueUnion.psz, "BusLogic"))
                 {
-                    rc = machine->RemoveStorageController(Bstr("LsiLogic").raw());
+                    rc = sessionMachine->RemoveStorageController(Bstr("LsiLogic").raw());
                     if (FAILED(rc))
-                        CHECK_ERROR(machine, RemoveStorageController(Bstr("BusLogic").raw()));
-
-                    CHECK_ERROR(machine,
+                        CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("BusLogic").raw()));
+
+                    CHECK_ERROR(sessionMachine,
                                  AddStorageController(Bstr("BusLogic").raw(),
                                                       StorageBus_SCSI,
@@ -1086,5 +1088,5 @@
                     ComPtr<IStorageController> ctl;
 
-                    CHECK_ERROR(machine, AddStorageController(Bstr("BusLogic").raw(),
+                    CHECK_ERROR(sessionMachine, AddStorageController(Bstr("BusLogic").raw(),
                                                               StorageBus_SCSI,
                                                               ctl.asOutParam()));
@@ -1094,7 +1096,7 @@
                 else if (!RTStrICmp(ValueUnion.psz, "off") || !RTStrICmp(ValueUnion.psz, "disable"))
                 {
-                    rc = machine->RemoveStorageController(Bstr("BusLogic").raw());
+                    rc = sessionMachine->RemoveStorageController(Bstr("BusLogic").raw());
                     if (FAILED(rc))
-                        CHECK_ERROR(machine, RemoveStorageController(Bstr("LsiLogic").raw()));
+                        CHECK_ERROR(sessionMachine, RemoveStorageController(Bstr("LsiLogic").raw()));
                 }
                 break;
@@ -1103,5 +1105,5 @@
             case MODIFYVM_DVDPASSTHROUGH: // deprecated
             {
-                CHECK_ERROR(machine, PassthroughDevice(Bstr("IDE Controller").raw(),
+                CHECK_ERROR(sessionMachine, PassthroughDevice(Bstr("IDE Controller").raw(),
                                                        1, 0,
                                                        !RTStrICmp(ValueUnion.psz, "on")));
@@ -1160,5 +1162,5 @@
                 }
 
-                CHECK_ERROR(machine, MountMedium(Bstr("IDE Controller").raw(),
+                CHECK_ERROR(sessionMachine, MountMedium(Bstr("IDE Controller").raw(),
                                                  1, 0,
                                                  dvdMedium,
@@ -1171,5 +1173,5 @@
                 ComPtr<IMedium> floppyMedium;
                 ComPtr<IMediumAttachment> floppyAttachment;
-                machine->GetMediumAttachment(Bstr("Floppy Controller").raw(),
+                sessionMachine->GetMediumAttachment(Bstr("Floppy Controller").raw(),
                                              0, 0, floppyAttachment.asOutParam());
 
@@ -1179,5 +1181,5 @@
                     /* disable the controller */
                     if (floppyAttachment)
-                        CHECK_ERROR(machine, DetachDevice(Bstr("Floppy Controller").raw(),
+                        CHECK_ERROR(sessionMachine, DetachDevice(Bstr("Floppy Controller").raw(),
                                                           0, 0));
                 }
@@ -1186,5 +1188,5 @@
                     /* enable the controller */
                     if (!floppyAttachment)
-                        CHECK_ERROR(machine, AttachDeviceWithoutMedium(Bstr("Floppy Controller").raw(),
+                        CHECK_ERROR(sessionMachine, AttachDeviceWithoutMedium(Bstr("Floppy Controller").raw(),
                                                                             0, 0,
                                                                             DeviceType_Floppy));
@@ -1224,5 +1226,5 @@
                         }
                     }
-                    CHECK_ERROR(machine, MountMedium(Bstr("Floppy Controller").raw(),
+                    CHECK_ERROR(sessionMachine, MountMedium(Bstr("Floppy Controller").raw(),
                                                      0, 0,
                                                      floppyMedium,
@@ -1239,5 +1241,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1252,5 +1254,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1265,5 +1267,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1304,5 +1306,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1349,5 +1351,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1362,5 +1364,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1402,5 +1404,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1415,5 +1417,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1428,5 +1430,5 @@
                     ComPtr<IBandwidthGroup> bwGroup;
 
-                    CHECK_ERROR(machine, COMGETTER(BandwidthControl)(bwCtrl.asOutParam()));
+                    CHECK_ERROR(sessionMachine, COMGETTER(BandwidthControl)(bwCtrl.asOutParam()));
 
                     if (SUCCEEDED(rc))
@@ -1448,5 +1450,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1508,5 +1510,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1521,5 +1523,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1542,5 +1544,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1563,5 +1565,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1584,5 +1586,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1597,5 +1599,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1610,5 +1612,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1630,5 +1632,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1680,5 +1682,5 @@
                     break;
 
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1696,5 +1698,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1759,5 +1761,5 @@
                 uint32_t aliasMode = 0;
 
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1792,5 +1794,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1808,5 +1810,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1824,5 +1826,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1839,5 +1841,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1855,5 +1857,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1871,5 +1873,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1886,5 +1888,5 @@
 
                 ComPtr<INetworkAdapter> nic;
-                CHECK_ERROR_BREAK(machine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(GetOptState.uIndex - 1, nic.asOutParam()));
                 ASSERT(nic);
 
@@ -1906,9 +1908,9 @@
                 if (!RTStrICmp(ValueUnion.psz, "ps2"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(PointingHIDType)(PointingHIDType_PS2Mouse));
+                    CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_PS2Mouse));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "usb"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(PointingHIDType)(PointingHIDType_USBMouse));
+                    CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBMouse));
                     if (SUCCEEDED(rc))
                         fEnableUsb = true;
@@ -1916,5 +1918,5 @@
                 else if (!RTStrICmp(ValueUnion.psz, "usbtablet"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(PointingHIDType)(PointingHIDType_USBTablet));
+                    CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBTablet));
                     if (SUCCEEDED(rc))
                         fEnableUsb = true;
@@ -1922,5 +1924,5 @@
                 else if (!RTStrICmp(ValueUnion.psz, "usbmultitouch"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(PointingHIDType)(PointingHIDType_USBMultiTouch));
+                    CHECK_ERROR(sessionMachine, COMSETTER(PointingHIDType)(PointingHIDType_USBMultiTouch));
                     if (SUCCEEDED(rc))
                         fEnableUsb = true;
@@ -1935,10 +1937,10 @@
                     /* Make sure the OHCI controller is enabled. */
                     ULONG cOhciCtrls = 0;
-                    rc = machine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
+                    rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
                     if (   SUCCEEDED(rc)
                         && !cOhciCtrls)
                     {
                         ComPtr<IUSBController> UsbCtl;
-                        CHECK_ERROR(machine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
+                        CHECK_ERROR(sessionMachine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
                                                               UsbCtl.asOutParam()));
                     }
@@ -1952,9 +1954,9 @@
                 if (!RTStrICmp(ValueUnion.psz, "ps2"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_PS2Keyboard));
+                    CHECK_ERROR(sessionMachine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_PS2Keyboard));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "usb"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_USBKeyboard));
+                    CHECK_ERROR(sessionMachine, COMSETTER(KeyboardHIDType)(KeyboardHIDType_USBKeyboard));
                     if (SUCCEEDED(rc))
                         fEnableUsb = true;
@@ -1969,10 +1971,10 @@
                     /* Make sure the OHCI controller is enabled. */
                     ULONG cOhciCtrls = 0;
-                    rc = machine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
+                    rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
                     if (   SUCCEEDED(rc)
                         && !cOhciCtrls)
                     {
                         ComPtr<IUSBController> UsbCtl;
-                        CHECK_ERROR(machine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
+                        CHECK_ERROR(sessionMachine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
                                                               UsbCtl.asOutParam()));
                     }
@@ -1986,5 +1988,5 @@
                 char *pszIRQ = NULL;
 
-                CHECK_ERROR_BREAK(machine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
                 ASSERT(uart);
 
@@ -2034,5 +2036,5 @@
                 ComPtr<ISerialPort> uart;
 
-                CHECK_ERROR_BREAK(machine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetSerialPort(GetOptState.uIndex - 1, uart.asOutParam()));
                 ASSERT(uart);
 
@@ -2068,5 +2070,5 @@
                 char *pszIRQ = NULL;
 
-                CHECK_ERROR_BREAK(machine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
                 ASSERT(lpt);
 
@@ -2079,5 +2081,5 @@
                 ComPtr<IParallelPort> lpt;
 
-                CHECK_ERROR_BREAK(machine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, GetParallelPort(GetOptState.uIndex - 1, lpt.asOutParam()));
                 ASSERT(lpt);
 
@@ -2110,5 +2112,5 @@
             case MODIFYVM_GUESTMEMORYBALLOON:
             {
-                CHECK_ERROR(machine, COMSETTER(MemoryBalloonSize)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(MemoryBalloonSize)(ValueUnion.u32));
                 break;
             }
@@ -2117,5 +2119,5 @@
             {
                 ComPtr<IAudioAdapter> audioAdapter;
-                machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
+                sessionMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
                 ASSERT(audioAdapter);
 
@@ -2137,5 +2139,5 @@
             {
                 ComPtr<IAudioAdapter> audioAdapter;
-                machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
+                sessionMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
                 ASSERT(audioAdapter);
 
@@ -2242,5 +2244,5 @@
                 if (SUCCEEDED(rc))
                 {
-                    CHECK_ERROR(machine, COMSETTER(ClipboardMode)(mode));
+                    CHECK_ERROR(sessionMachine, COMSETTER(ClipboardMode)(mode));
                 }
                 break;
@@ -2265,5 +2267,5 @@
                 if (SUCCEEDED(rc))
                 {
-                    CHECK_ERROR(machine, COMSETTER(DnDMode)(mode));
+                    CHECK_ERROR(sessionMachine, COMSETTER(DnDMode)(mode));
                 }
                 break;
@@ -2273,5 +2275,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2292,5 +2294,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2335,5 +2337,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2351,5 +2353,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2363,5 +2365,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2389,5 +2391,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2410,5 +2412,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2422,5 +2424,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2434,5 +2436,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2447,5 +2449,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2460,5 +2462,5 @@
             {
                 ComPtr<IVRDEServer> vrdeServer;
-                machine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
+                sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
                 ASSERT(vrdeServer);
 
@@ -2470,5 +2472,5 @@
             {
                 ULONG cXhciCtrls = 0;
-                rc = machine->GetUSBControllerCountByType(USBControllerType_XHCI, &cXhciCtrls);
+                rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_XHCI, &cXhciCtrls);
                 if (SUCCEEDED(rc))
                 {
@@ -2476,9 +2478,9 @@
                     {
                         ComPtr<IUSBController> UsbCtl;
-                        CHECK_ERROR(machine, AddUSBController(Bstr("XHCI").raw(), USBControllerType_XHCI,
+                        CHECK_ERROR(sessionMachine, AddUSBController(Bstr("XHCI").raw(), USBControllerType_XHCI,
                                                               UsbCtl.asOutParam()));
                     }
                     else if (cXhciCtrls && !ValueUnion.f)
-                        CHECK_ERROR(machine, RemoveUSBController(Bstr("XHCI").raw()));
+                        CHECK_ERROR(sessionMachine, RemoveUSBController(Bstr("XHCI").raw()));
                 }
                 break;
@@ -2488,5 +2490,5 @@
             {
                 ULONG cEhciCtrls = 0;
-                rc = machine->GetUSBControllerCountByType(USBControllerType_EHCI, &cEhciCtrls);
+                rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_EHCI, &cEhciCtrls);
                 if (SUCCEEDED(rc))
                 {
@@ -2494,9 +2496,9 @@
                     {
                         ComPtr<IUSBController> UsbCtl;
-                        CHECK_ERROR(machine, AddUSBController(Bstr("EHCI").raw(), USBControllerType_EHCI,
+                        CHECK_ERROR(sessionMachine, AddUSBController(Bstr("EHCI").raw(), USBControllerType_EHCI,
                                                               UsbCtl.asOutParam()));
                     }
                     else if (cEhciCtrls && !ValueUnion.f)
-                        CHECK_ERROR(machine, RemoveUSBController(Bstr("EHCI").raw()));
+                        CHECK_ERROR(sessionMachine, RemoveUSBController(Bstr("EHCI").raw()));
                 }
                 break;
@@ -2506,5 +2508,5 @@
             {
                 ULONG cOhciCtrls = 0;
-                rc = machine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
+                rc = sessionMachine->GetUSBControllerCountByType(USBControllerType_OHCI, &cOhciCtrls);
                 if (SUCCEEDED(rc))
                 {
@@ -2512,9 +2514,9 @@
                     {
                         ComPtr<IUSBController> UsbCtl;
-                        CHECK_ERROR(machine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
+                        CHECK_ERROR(sessionMachine, AddUSBController(Bstr("OHCI").raw(), USBControllerType_OHCI,
                                                               UsbCtl.asOutParam()));
                     }
                     else if (cOhciCtrls && !ValueUnion.f)
-                        CHECK_ERROR(machine, RemoveUSBController(Bstr("OHCI").raw()));
+                        CHECK_ERROR(sessionMachine, RemoveUSBController(Bstr("OHCI").raw()));
                 }
                 break;
@@ -2524,7 +2526,7 @@
             {
                 if (!RTStrICmp(ValueUnion.psz, "default"))
-                    CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr().raw()));
-                else
-                    CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(ValueUnion.psz).raw()));
+                    CHECK_ERROR(sessionMachine, COMSETTER(SnapshotFolder)(Bstr().raw()));
+                else
+                    CHECK_ERROR(sessionMachine, COMSETTER(SnapshotFolder)(Bstr(ValueUnion.psz).raw()));
                 break;
             }
@@ -2532,5 +2534,5 @@
             case MODIFYVM_TELEPORTER_ENABLED:
             {
-                CHECK_ERROR(machine, COMSETTER(TeleporterEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(TeleporterEnabled)(ValueUnion.f));
                 break;
             }
@@ -2538,5 +2540,5 @@
             case MODIFYVM_TELEPORTER_PORT:
             {
-                CHECK_ERROR(machine, COMSETTER(TeleporterPort)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(TeleporterPort)(ValueUnion.u32));
                 break;
             }
@@ -2544,5 +2546,5 @@
             case MODIFYVM_TELEPORTER_ADDRESS:
             {
-                CHECK_ERROR(machine, COMSETTER(TeleporterAddress)(Bstr(ValueUnion.psz).raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(TeleporterAddress)(Bstr(ValueUnion.psz).raw()));
                 break;
             }
@@ -2550,5 +2552,5 @@
             case MODIFYVM_TELEPORTER_PASSWORD:
             {
-                CHECK_ERROR(machine, COMSETTER(TeleporterPassword)(Bstr(ValueUnion.psz).raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(TeleporterPassword)(Bstr(ValueUnion.psz).raw()));
                 break;
             }
@@ -2561,5 +2563,5 @@
                     rc = E_FAIL;
                 else
-                    CHECK_ERROR(machine, COMSETTER(TeleporterPassword)(Bstr(password).raw()));
+                    CHECK_ERROR(sessionMachine, COMSETTER(TeleporterPassword)(Bstr(password).raw()));
                 break;
             }
@@ -2567,5 +2569,5 @@
             case MODIFYVM_TRACING_ENABLED:
             {
-                CHECK_ERROR(machine, COMSETTER(TracingEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(TracingEnabled)(ValueUnion.f));
                 break;
             }
@@ -2573,5 +2575,5 @@
             case MODIFYVM_TRACING_CONFIG:
             {
-                CHECK_ERROR(machine, COMSETTER(TracingConfig)(Bstr(ValueUnion.psz).raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(TracingConfig)(Bstr(ValueUnion.psz).raw()));
                 break;
             }
@@ -2579,5 +2581,5 @@
             case MODIFYVM_TRACING_ALLOW_VM_ACCESS:
             {
-                CHECK_ERROR(machine, COMSETTER(AllowTracingToAccessVM)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(AllowTracingToAccessVM)(ValueUnion.f));
                 break;
             }
@@ -2587,10 +2589,10 @@
                 if (!RTStrICmp(ValueUnion.psz, "master"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(FaultToleranceState(FaultToleranceState_Master)));
+                    CHECK_ERROR(sessionMachine, COMSETTER(FaultToleranceState(FaultToleranceState_Master)));
                 }
                 else
                 if (!RTStrICmp(ValueUnion.psz, "standby"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(FaultToleranceState(FaultToleranceState_Standby)));
+                    CHECK_ERROR(sessionMachine, COMSETTER(FaultToleranceState(FaultToleranceState_Standby)));
                 }
                 else
@@ -2604,5 +2606,5 @@
             case MODIFYVM_FAULT_TOLERANCE_ADDRESS:
             {
-                CHECK_ERROR(machine, COMSETTER(FaultToleranceAddress)(Bstr(ValueUnion.psz).raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(FaultToleranceAddress)(Bstr(ValueUnion.psz).raw()));
                 break;
             }
@@ -2610,5 +2612,5 @@
             case MODIFYVM_FAULT_TOLERANCE_PORT:
             {
-                CHECK_ERROR(machine, COMSETTER(FaultTolerancePort)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(FaultTolerancePort)(ValueUnion.u32));
                 break;
             }
@@ -2616,5 +2618,5 @@
             case MODIFYVM_FAULT_TOLERANCE_PASSWORD:
             {
-                CHECK_ERROR(machine, COMSETTER(FaultTolerancePassword)(Bstr(ValueUnion.psz).raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(FaultTolerancePassword)(Bstr(ValueUnion.psz).raw()));
                 break;
             }
@@ -2622,5 +2624,5 @@
             case MODIFYVM_FAULT_TOLERANCE_SYNC_INTERVAL:
             {
-                CHECK_ERROR(machine, COMSETTER(FaultToleranceSyncInterval)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(FaultToleranceSyncInterval)(ValueUnion.u32));
                 break;
             }
@@ -2628,5 +2630,5 @@
             case MODIFYVM_HARDWARE_UUID:
             {
-                CHECK_ERROR(machine, COMSETTER(HardwareUUID)(Bstr(ValueUnion.psz).raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(HardwareUUID)(Bstr(ValueUnion.psz).raw()));
                 break;
             }
@@ -2634,5 +2636,5 @@
             case MODIFYVM_HPET:
             {
-                CHECK_ERROR(machine, COMSETTER(HPETEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(HPETEnabled)(ValueUnion.f));
                 break;
             }
@@ -2640,5 +2642,5 @@
             case MODIFYVM_IOCACHE:
             {
-                CHECK_ERROR(machine, COMSETTER(IOCacheEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(IOCacheEnabled)(ValueUnion.f));
                 break;
             }
@@ -2646,5 +2648,5 @@
             case MODIFYVM_IOCACHESIZE:
             {
-                CHECK_ERROR(machine, COMSETTER(IOCacheSize)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(IOCacheSize)(ValueUnion.u32));
                 break;
             }
@@ -2654,9 +2656,9 @@
                 if (!RTStrICmp(ValueUnion.psz, "piix3"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(ChipsetType)(ChipsetType_PIIX3));
+                    CHECK_ERROR(sessionMachine, COMSETTER(ChipsetType)(ChipsetType_PIIX3));
                 }
                 else if (!RTStrICmp(ValueUnion.psz, "ich9"))
                 {
-                    CHECK_ERROR(machine, COMSETTER(ChipsetType)(ChipsetType_ICH9));
+                    CHECK_ERROR(sessionMachine, COMSETTER(ChipsetType)(ChipsetType_ICH9));
                     BOOL fIoApic = FALSE;
                     CHECK_ERROR(biosSettings, COMGETTER(IOAPICEnabled)(&fIoApic));
@@ -2677,5 +2679,5 @@
             case MODIFYVM_VCP:
             {
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureEnabled)(ValueUnion.f));
                 break;
             }
@@ -2683,5 +2685,5 @@
             {
                 ULONG cMonitors = 64;
-                CHECK_ERROR(machine, COMGETTER(MonitorCount)(&cMonitors));
+                CHECK_ERROR(sessionMachine, COMGETTER(MonitorCount)(&cMonitors));
                 com::SafeArray<BOOL> screens(cMonitors);
                 if (parseScreens(ValueUnion.psz, &screens))
@@ -2691,5 +2693,5 @@
                     break;
                 }
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureScreens)(ComSafeArrayAsInParam(screens)));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureScreens)(ComSafeArrayAsInParam(screens)));
                 break;
             }
@@ -2710,35 +2712,35 @@
                     bstr = szVCFileAbs;
                 }
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureFile)(bstr.raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureFile)(bstr.raw()));
                 break;
             }
             case MODIFYVM_VCP_WIDTH:
             {
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureWidth)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureWidth)(ValueUnion.u32));
                 break;
             }
             case MODIFYVM_VCP_HEIGHT:
             {
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureHeight)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureHeight)(ValueUnion.u32));
                 break;
             }
             case MODIFYVM_VCP_RATE:
             {
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureRate)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureRate)(ValueUnion.u32));
                 break;
             }
             case MODIFYVM_VCP_FPS:
             {
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureFPS)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureFPS)(ValueUnion.u32));
                 break;
             }
             case MODIFYVM_VCP_MAXTIME:
             {
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureMaxTime)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureMaxTime)(ValueUnion.u32));
                 break;
             }
             case MODIFYVM_VCP_MAXSIZE:
             {
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureMaxFileSize)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureMaxFileSize)(ValueUnion.u32));
                 break;
             }
@@ -2746,5 +2748,5 @@
             {
                 Bstr bstr(ValueUnion.psz);
-                CHECK_ERROR(machine, COMSETTER(VideoCaptureOptions)(bstr.raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(VideoCaptureOptions)(bstr.raw()));
                 break;
             }
@@ -2752,5 +2754,5 @@
             case MODIFYVM_AUTOSTART_ENABLED:
             {
-                CHECK_ERROR(machine, COMSETTER(AutostartEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(AutostartEnabled)(ValueUnion.f));
                 break;
             }
@@ -2758,5 +2760,5 @@
             case MODIFYVM_AUTOSTART_DELAY:
             {
-                CHECK_ERROR(machine, COMSETTER(AutostartDelay)(ValueUnion.u32));
+                CHECK_ERROR(sessionMachine, COMSETTER(AutostartDelay)(ValueUnion.u32));
                 break;
             }
@@ -2781,5 +2783,5 @@
 
                 if (SUCCEEDED(rc))
-                    CHECK_ERROR(machine, COMSETTER(AutostopType)(enmAutostopType));
+                    CHECK_ERROR(sessionMachine, COMSETTER(AutostopType)(enmAutostopType));
                 break;
             }
@@ -2800,5 +2802,5 @@
                 else
                 {
-                    CHECK_ERROR(machine, AttachHostPCIDevice(iHostAddr, iGuestAddr, TRUE));
+                    CHECK_ERROR(sessionMachine, AttachHostPCIDevice(iHostAddr, iGuestAddr, TRUE));
                 }
 
@@ -2817,5 +2819,5 @@
                 else
                 {
-                    CHECK_ERROR(machine, DetachHostPCIDevice(iHostAddr));
+                    CHECK_ERROR(sessionMachine, DetachHostPCIDevice(iHostAddr));
                 }
 
@@ -2827,5 +2829,5 @@
             case MODIFYVM_USBCARDREADER:
             {
-                CHECK_ERROR(machine, COMSETTER(EmulatedUSBCardReaderEnabled)(ValueUnion.f));
+                CHECK_ERROR(sessionMachine, COMSETTER(EmulatedUSBCardReaderEnabled)(ValueUnion.f));
                 break;
             }
@@ -2837,5 +2839,5 @@
                 if (bstr == "default")
                     bstr = Bstr::Empty;
-                CHECK_ERROR(machine, COMSETTER(DefaultFrontend)(bstr.raw()));
+                CHECK_ERROR(sessionMachine, COMSETTER(DefaultFrontend)(bstr.raw()));
                 break;
             }
@@ -2852,5 +2854,5 @@
     /* commit changes */
     if (SUCCEEDED(rc))
-        CHECK_ERROR(machine, SaveSettings());
+        CHECK_ERROR(sessionMachine, SaveSettings());
 
     /* it's important to always close sessions */
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp	(revision 55233)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageSnapshot.cpp	(revision 55234)
@@ -198,5 +198,5 @@
     {
         ComPtr<ISnapshot> pCurrentSnapshot;
-        CHECK_ERROR2_RET(pMachine,COMGETTER(CurrentSnapshot)(pCurrentSnapshot.asOutParam()), RTEXITCODE_FAILURE);
+        CHECK_ERROR2_RET(pMachine, COMGETTER(CurrentSnapshot)(pCurrentSnapshot.asOutParam()), RTEXITCODE_FAILURE);
         hrc = showSnapshots(pSnapshot, pCurrentSnapshot, enmDetails);
         if (FAILED(hrc))
@@ -286,5 +286,6 @@
     {
         /* replace the (read-only) IMachine object by a writable one */
-        CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(pMachine.asOutParam()));
+        ComPtr<IMachine> sessionMachine;
+        CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()));
 
         /* switch based on the command */
@@ -347,7 +348,7 @@
 
             ComPtr<IProgress> progress;
-            CHECK_ERROR_BREAK(pMachine, TakeSnapshot(name.raw(), desc.raw(),
-                                                     fPause,
-                                                     progress.asOutParam()));
+            CHECK_ERROR_BREAK(sessionMachine, TakeSnapshot(name.raw(), desc.raw(),
+                                                           fPause,
+                                                           progress.asOutParam()));
 
             rc = showProgress(progress);
@@ -382,10 +383,10 @@
             if (fRestoreCurrent)
             {
-                CHECK_ERROR_BREAK(pMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
             }
             else
             {
                 // restore or delete snapshot: then resolve cmd line argument to snapshot instance
-                CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
+                CHECK_ERROR_BREAK(sessionMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
                                                          pSnapshot.asOutParam()));
             }
@@ -395,5 +396,5 @@
             if (fDelete)
             {
-                CHECK_ERROR_BREAK(pMachine, DeleteSnapshot(bstrSnapGuid.raw(),
+                CHECK_ERROR_BREAK(sessionMachine, DeleteSnapshot(bstrSnapGuid.raw(),
                                                            pProgress.asOutParam()));
             }
@@ -402,5 +403,5 @@
                 // restore or restore current
                 RTPrintf("Restoring snapshot %ls\n", bstrSnapGuid.raw());
-                CHECK_ERROR_BREAK(pMachine, RestoreSnapshot(pSnapshot, pProgress.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, RestoreSnapshot(pSnapshot, pProgress.asOutParam()));
             }
 
@@ -422,9 +423,9 @@
                 || !strcmp(a->argv[2], "-current"))
             {
-                CHECK_ERROR_BREAK(pMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
+                CHECK_ERROR_BREAK(sessionMachine, COMGETTER(CurrentSnapshot)(pSnapshot.asOutParam()));
             }
             else
             {
-                CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
+                CHECK_ERROR_BREAK(sessionMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
                                                          pSnapshot.asOutParam()));
             }
@@ -480,6 +481,6 @@
             ComPtr<ISnapshot> pSnapshot;
 
-            CHECK_ERROR_BREAK(pMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
-                                                     pSnapshot.asOutParam()));
+            CHECK_ERROR_BREAK(sessionMachine, FindSnapshot(Bstr(a->argv[2]).raw(),
+                                                           pSnapshot.asOutParam()));
 
             /* get the machine of the given snapshot */
@@ -489,7 +490,7 @@
         }
         else if (!strcmp(a->argv[1], "list"))
-            rc = handleSnapshotList(a, pMachine) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL;
+            rc = handleSnapshotList(a, sessionMachine) == RTEXITCODE_SUCCESS ? S_OK : E_FAIL;
         else if (!strcmp(a->argv[1], "dump"))          // undocumented parameter to debug snapshot info
-            DumpSnapshot(pMachine);
+            DumpSnapshot(sessionMachine);
         else
         {
