Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 52976)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 52977)
@@ -372,43 +372,4 @@
 
     return *mSelectorWnd;
-}
-
-bool VBoxGlobal::startMachine(const QString &strMachineId)
-{
-    /* Some restrictions: */
-    AssertMsg(mValid, ("VBoxGlobal is invalid"));
-    AssertMsg(!m_pVirtualMachine, ("Machine already started"));
-
-    /* Restore current snapshot if asked to do so: */
-    if (mRestoreCurrentSnapshot)
-    {
-        CSession session = vboxGlobal().openSession(strMachineId, KLockType_VM);
-        if (session.isNull())
-            return false;
-
-        CConsole  console  = session.GetConsole();
-        CMachine  machine  = session.GetMachine();
-        CSnapshot snapshot = machine.GetCurrentSnapshot();
-        CProgress progress = console.RestoreSnapshot(snapshot);
-        if (!console.isOk())
-            return msgCenter().cannotRestoreSnapshot(console, snapshot.GetName(), machine.GetName());
-
-        /* Show the snapshot-discard progress: */
-        msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png");
-        if (progress.GetResultCode() != 0)
-            return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machine.GetName());
-        session.UnlockMachine();
-
-        /* Clear the restore flag so media enum can be started, should be safe now. */
-        mRestoreCurrentSnapshot = false;
-    }
-
-    /* Start virtual machine: */
-    return UIMachine::create(&m_pVirtualMachine);
-}
-
-UIMachine* VBoxGlobal::virtualMachine()
-{
-    return m_pVirtualMachine;
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 52976)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 52977)
@@ -110,7 +110,9 @@
     UISelectorWindow &selectorWnd();
 
-    /* VM stuff: */
-    bool startMachine(const QString &strMachineId);
-    UIMachine* virtualMachine();
+    /** Returns current virtual machine. */
+    UIMachine* virtualMachine() const { return m_pVirtualMachine; }
+    /** Defines current virtual @a pMachine. */
+    void setVirtualMachine(UIMachine *pMachine) { m_pVirtualMachine = pMachine; }
+
     QWidget* activeMachineWindow();
 
@@ -140,5 +142,9 @@
     bool isKWinManaged() const { return mIsKWinManaged; }
 
+    /** Returns whether we should restore current snapshot before VM started. */
     bool shouldRestoreCurrentSnapshot() const { return mRestoreCurrentSnapshot; }
+    /** Defines whether we should fRestore current snapshot before VM started. */
+    void setShouldRestoreCurrentSnapshot(bool fRestore) { mRestoreCurrentSnapshot = fRestore; }
+
     bool isPatmDisabled() const { return mDisablePatm; }
     bool isCsamDisabled() const { return mDisableCsam; }
Index: /trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/main.cpp	(revision 52976)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/main.cpp	(revision 52977)
@@ -26,4 +26,5 @@
 # include "UIMessageCenter.h"
 # include "UISelectorWindow.h"
+# include "UIMachine.h"
 # include "VBoxUtils.h"
 # include "UIModalWindowManager.h"
@@ -456,5 +457,5 @@
             {
                 /* Make sure VM is started: */
-                if (!vboxGlobal().startMachine(vboxGlobal().managedVMUuid()))
+                if (!UIMachine::startMachine(vboxGlobal().managedVMUuid()))
                     break;
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 52976)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 52977)
@@ -30,4 +30,10 @@
 # include "UIMessageCenter.h"
 
+/* COM includes: */
+# include "CMachine.h"
+# include "CConsole.h"
+# include "CSnapshot.h"
+# include "CProgress.h"
+
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
@@ -91,15 +97,51 @@
 
 /* static */
-bool UIMachine::create(UIMachine **ppSelf)
-{
-    UIMachine *pMachine = new UIMachine(ppSelf);
-    if (!pMachine)
-        return false;
+bool UIMachine::startMachine(const QString &strID)
+{
+    /* Some restrictions: */
+    AssertMsgReturn(vboxGlobal().isValid(), ("VBoxGlobal is invalid.."), false);
+    AssertMsgReturn(!vboxGlobal().virtualMachine(), ("Machine already started.."), false);
+
+    /* Restore current snapshot if requested: */
+    if (vboxGlobal().shouldRestoreCurrentSnapshot())
+    {
+        /* Create temporary session: */
+        CSession session = vboxGlobal().openSession(strID, KLockType_VM);
+        if (session.isNull())
+            return false;
+
+        /* Which VM we operate on? */
+        CMachine machine  = session.GetMachine();
+        /* Which snapshot we are restoring? */
+        CSnapshot snapshot = machine.GetCurrentSnapshot();
+
+        /* Open corresponding console: */
+        CConsole console  = session.GetConsole();
+        /* Prepare restore-snapshot progress: */
+        CProgress progress = console.RestoreSnapshot(snapshot);
+        if (!console.isOk())
+            return msgCenter().cannotRestoreSnapshot(console, snapshot.GetName(), machine.GetName());
+
+        /* Show the snapshot-discarding progress: */
+        msgCenter().showModalProgressDialog(progress, machine.GetName(), ":/progress_snapshot_discard_90px.png");
+        if (progress.GetResultCode() != 0)
+            return msgCenter().cannotRestoreSnapshot(progress, snapshot.GetName(), machine.GetName());
+
+        /* Unlock session finally: */
+        session.UnlockMachine();
+
+        /* Clear snapshot-restoring request: */
+        vboxGlobal().setShouldRestoreCurrentSnapshot(false);
+    }
+
+    /* Create machine UI: */
+    UIMachine *pMachine = new UIMachine;
+
+    /* Prepare machine UI: */
     return pMachine->prepare();
 }
 
-UIMachine::UIMachine(UIMachine **ppSelf)
+UIMachine::UIMachine()
     : QObject(0)
-    , m_ppThis(ppSelf)
     , initialStateType(UIVisualStateType_Normal)
     , m_pSession(0)
@@ -107,7 +149,6 @@
     , m_allowedVisualStates(UIVisualStateType_Invalid)
 {
-    /* Store self pointer: */
-    if (m_ppThis)
-        *m_ppThis = this;
+    /* Make sure VBoxGlobal is aware of VM creation: */
+    vboxGlobal().setVirtualMachine(this);
 }
 
@@ -192,6 +233,6 @@
     m_session.detach();
 
-    /* Clear self pointer: */
-    *m_ppThis = 0;
+    /* Make sure VBoxGlobal is aware of VM destruction: */
+    vboxGlobal().setVirtualMachine(0);
 
     /* Quit application: */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 52976)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 52977)
@@ -46,8 +46,11 @@
 public:
 
-    static bool create(UIMachine **ppSelf);
+    /** Static factory to start machine with passed @a strID.
+      * @return true if machine was started, false otherwise. */
+    static bool startMachine(const QString &strID);
 
-    /* Virtual Machine constructor/destructor: */
-    UIMachine(UIMachine **ppSelf);
+    /** Constructor. */
+    UIMachine();
+    /** Destructor. */
     virtual ~UIMachine();
 
@@ -84,5 +87,4 @@
 
     /* Private variables: */
-    UIMachine **m_ppThis;
     UIVisualStateType initialStateType;
     CSession m_session;
