Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 52990)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp	(revision 52991)
@@ -221,5 +221,4 @@
     : mValid (false)
     , mSelectorWnd (NULL)
-    , m_pVirtualMachine(0)
     , m_fSeparateProcess(false)
     , m_pMediumEnumerator(0)
@@ -374,13 +373,15 @@
 }
 
-QWidget* VBoxGlobal::activeMachineWindow()
-{
-    /* Null if that is NOT console-process or machine not yet created: */
-    if (!isVMConsoleProcess() || !m_pVirtualMachine)
-        return 0;
-    /* Active machine-window otherwise: */
-    return m_pVirtualMachine->activeWindow();
-}
-
+UIMachine* VBoxGlobal::virtualMachine() const
+{
+    return gpMachine;
+}
+
+QWidget* VBoxGlobal::activeMachineWindow() const
+{
+    if (isVMConsoleProcess() && gpMachine && gpMachine->activeWindow())
+        return gpMachine->activeWindow();
+    return 0;
+}
 
 /**
@@ -4246,10 +4247,6 @@
         mSelectorWnd = NULL;
     }
-
-    if (m_pVirtualMachine)
-    {
-        delete m_pVirtualMachine;
-        m_pVirtualMachine = NULL;
-    }
+    if (gpMachine)
+        UIMachine::destroy();
 
     /* Cleanup medium-enumerator: */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 52990)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h	(revision 52991)
@@ -111,9 +111,7 @@
 
     /** Returns current virtual machine. */
-    UIMachine* virtualMachine() const { return m_pVirtualMachine; }
-    /** Defines current virtual @a pMachine. */
-    void setVirtualMachine(UIMachine *pMachine) { m_pVirtualMachine = pMachine; }
-
-    QWidget* activeMachineWindow();
+    UIMachine* virtualMachine() const;
+    /** Returns currently active virtual machine window. */
+    QWidget* activeMachineWindow() const;
 
     bool is3DAvailableWorker() const;
@@ -437,5 +435,4 @@
 
     UISelectorWindow *mSelectorWnd;
-    UIMachine *m_pVirtualMachine;
 
     /** Holds whether GUI is separate (from VM) process. */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 52990)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 52991)
@@ -97,4 +97,7 @@
 
 /* static */
+UIMachine* UIMachine::m_spInstance = 0;
+
+/* static */
 bool UIMachine::startMachine(const QString &strID)
 {
@@ -136,8 +139,17 @@
 
     /* Create machine UI: */
-    UIMachine *pMachine = new UIMachine;
-
+    new UIMachine;
     /* Prepare machine UI: */
-    return pMachine->prepare();
+    return m_spInstance->prepare();
+}
+
+/* static */
+void UIMachine::destroy()
+{
+    /* Cleanup machine UI: */
+    m_spInstance->cleanup();
+    /* Destroy machine UI: */
+    delete m_spInstance;
+    m_spInstance = 0;
 }
 
@@ -195,15 +207,10 @@
     , m_pVisualState(0)
 {
-    /* Make sure VBoxGlobal is aware of VM creation: */
-    vboxGlobal().setVirtualMachine(this);
+    m_spInstance = this;
 }
 
 UIMachine::~UIMachine()
 {
-    /* Make sure VBoxGlobal is aware of VM destruction: */
-    vboxGlobal().setVirtualMachine(0);
-
-    /* Cleanup machine UI: */
-    cleanup();
+    m_spInstance = 0;
 }
 
@@ -335,7 +342,4 @@
     m_session.detach();
 
-    /* Make sure VBoxGlobal is aware of VM destruction: */
-    vboxGlobal().setVirtualMachine(0);
-
     /* Quit application: */
     QApplication::quit();
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 52990)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 52991)
@@ -51,4 +51,8 @@
       * @return true if machine was started, false otherwise. */
     static bool startMachine(const QString &strID);
+    /** Static destructor. */
+    static void destroy();
+    /** Static instance. */
+    static UIMachine* instance() { return m_spInstance; }
 
     /** Returns UI session instance. */
@@ -89,4 +93,7 @@
     void enterInitialVisualState();
 
+    /** Static instance. */
+    static UIMachine* m_spInstance;
+
     /** Holds the session instance. */
     CSession m_session;
@@ -101,8 +108,7 @@
     /** Holds current visual state. */
     UIVisualState *m_pVisualState;
-
-    /* Temporary access: */
-    friend class VBoxGlobal;
 };
 
+#define gpMachine UIMachine::instance()
+
 #endif /* !___UIMachine_h___ */
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 52990)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 52991)
@@ -678,5 +678,5 @@
         if (!pWidget->isHidden())
             pWidget->hide();
-        /* Restart this slot asynchronously: */
+        /* Restart this slot: */
         emit sigCloseRuntimeUI();
         return;
@@ -684,5 +684,5 @@
 
     /* Finally close the Runtime UI: */
-    m_pMachine->deleteLater();
+    UIMachine::destroy();
 }
 
