Index: /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 53040)
+++ /trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk	(revision 53041)
@@ -490,5 +490,4 @@
 	src/runtime/UIActionPoolRuntime.cpp \
 	src/runtime/UIIndicatorsPool.cpp \
-	src/runtime/UIMachine.cpp \
 	src/runtime/UIMenuBarEditorWindow.cpp \
 	src/runtime/UIStatusBarEditorWindow.cpp \
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 53040)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 53041)
@@ -39,62 +39,4 @@
 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
 
-
-/* Visual state interface: */
-class UIVisualState : public QObject
-{
-    Q_OBJECT;
-
-public:
-
-    /* Constructor: */
-    UIVisualState(QObject *pParent, UISession *pSession, UIVisualStateType type)
-        : QObject(pParent)
-        , m_type(type)
-        , m_pSession(pSession)
-        , m_pMachineLogic(0)
-    {
-    }
-
-    /* Destructor: */
-    ~UIVisualState()
-    {
-        /* Cleanup/delete machine logic if exists: */
-        if (m_pMachineLogic)
-        {
-            /* Cleanup the logic object: */
-            m_pMachineLogic->cleanup();
-            /* Destroy the logic object: */
-            UIMachineLogic::destroy(m_pMachineLogic);
-        }
-    }
-
-    /* Visual state type getter: */
-    UIVisualStateType visualStateType() const { return m_type; }
-
-    /* Machine logic getter: */
-    UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
-
-    /* Method to prepare change one visual state to another: */
-    bool prepareChange()
-    {
-        m_pMachineLogic = UIMachineLogic::create(this, m_pSession, visualStateType());
-        return m_pMachineLogic->checkAvailability();
-    }
-
-    /* Method to change one visual state to another: */
-    void change()
-    {
-        /* Prepare the logic object: */
-        m_pMachineLogic->prepare();
-    }
-
-protected:
-
-    /* Variables: */
-    UIVisualStateType m_type;
-    UISession *m_pSession;
-    UIMachineLogic *m_pMachineLogic;
-};
-
 /* static */
 UIMachine* UIMachine::m_spInstance = 0;
@@ -188,11 +130,4 @@
 }
 
-UIMachineLogic* UIMachine::machineLogic() const
-{
-    if (m_pVisualState && m_pVisualState->machineLogic())
-        return m_pVisualState->machineLogic();
-    return 0;
-}
-
 QWidget* UIMachine::activeWindow() const
 {
@@ -202,33 +137,46 @@
 }
 
-void UIMachine::asyncChangeVisualState(UIVisualStateType visualStateType)
-{
-    emit sigRequestAsyncVisualStateChange(visualStateType);
-}
-
-void UIMachine::sltChangeVisualState(UIVisualStateType newVisualStateType)
-{
-    /* Create new state: */
-    UIVisualState *pNewVisualState = new UIVisualState(this, m_pSession, newVisualStateType);
-
-    /* First we have to check if the selected mode is available at all.
-     * Only then we delete the old mode and switch to the new mode. */
-    if (pNewVisualState->prepareChange())
-    {
-        /* Delete previous state: */
-        delete m_pVisualState;
-
-        /* Set the new mode as current mode: */
-        m_pVisualState = pNewVisualState;
-        m_pVisualState->change();
+void UIMachine::asyncChangeVisualState(UIVisualStateType visualState)
+{
+    emit sigRequestAsyncVisualStateChange(visualState);
+}
+
+void UIMachine::sltChangeVisualState(UIVisualStateType visualState)
+{
+    /* Create new machine-logic: */
+    UIMachineLogic *pMachineLogic = UIMachineLogic::create(this, m_pSession, visualState);
+
+    /* First we have to check if the selected machine-logic is available at all.
+     * Only then we delete the old machine-logic and switch to the new one. */
+    if (pMachineLogic->checkAvailability())
+    {
+        /* Delete previous machine-logic if exists: */
+        if (m_pMachineLogic)
+        {
+            m_pMachineLogic->cleanup();
+            UIMachineLogic::destroy(m_pMachineLogic);
+        }
+
+        /* Set the new machine-logic as current one: */
+        m_pMachineLogic = pMachineLogic;
+        m_pMachineLogic->prepare();
+
+        /* Remember new visual state: */
+        m_visualState = visualState;
     }
     else
     {
-        /* Discard the temporary created new state: */
-        delete pNewVisualState;
-
-        /* If there is no state currently created => we have to exit: */
-        if (!m_pVisualState)
-            deleteLater();
+        /* Delete temporary created machine-logic: */
+        pMachineLogic->cleanup();
+        UIMachineLogic::destroy(pMachineLogic);
+    }
+
+    /* Make sure machine-logic exists: */
+    if (!m_pMachineLogic)
+    {
+        /* Reset initial visual state  to normal: */
+        m_initialVisualState = UIVisualStateType_Normal;
+        /* Enter initial visual state again: */
+        enterInitialVisualState();
     }
 }
@@ -238,6 +186,7 @@
     , m_pSession(0)
     , m_allowedVisualStates(UIVisualStateType_Invalid)
-    , m_initialStateType(UIVisualStateType_Normal)
-    , m_pVisualState(0)
+    , m_initialVisualState(UIVisualStateType_Normal)
+    , m_visualState(UIVisualStateType_Invalid)
+    , m_pMachineLogic(0)
 {
     m_spInstance = this;
@@ -261,6 +210,6 @@
     vboxGlobal().startMediumEnumeration(false /* force start */);
 
-    /* Prepare visual state: */
-    prepareVisualState();
+    /* Prepare machine-logic: */
+    prepareMachineLogic();
 
     /* Now power up the machine.
@@ -287,5 +236,5 @@
 }
 
-void UIMachine::prepareVisualState()
+void UIMachine::prepareMachineLogic()
 {
     /* Prepare async visual state type change handler: */
@@ -308,6 +257,6 @@
         {
             /* Direct transition to scale/fullscreen mode allowed: */
-            case UIVisualStateType_Scale:      m_initialStateType = UIVisualStateType_Scale; break;
-            case UIVisualStateType_Fullscreen: m_initialStateType = UIVisualStateType_Fullscreen; break;
+            case UIVisualStateType_Scale:      m_initialVisualState = UIVisualStateType_Scale; break;
+            case UIVisualStateType_Fullscreen: m_initialVisualState = UIVisualStateType_Fullscreen; break;
             /* While to seamless is not, so we have to make request to do transition later: */
             case UIVisualStateType_Seamless:   uisession()->setRequestedVisualState(UIVisualStateType_Seamless); break;
@@ -320,5 +269,5 @@
 }
 
-void UIMachine::cleanupVisualState()
+void UIMachine::cleanupMachineLogic()
 {
     /* Session UI can have requested visual state: */
@@ -327,10 +276,7 @@
         /* Get requested visual state: */
         UIVisualStateType requestedVisualState = uisession()->requestedVisualState();
-        /* If requested state is invalid: */
+        /* Or current visual state if requested is invalid: */
         if (requestedVisualState == UIVisualStateType_Invalid)
-        {
-            /* Get current if still exists or normal otherwise: */
-            requestedVisualState = m_pVisualState ? m_pVisualState->visualStateType() : UIVisualStateType_Normal;
-        }
+            requestedVisualState = m_visualState;
 
         /* Save requested visual state: */
@@ -338,12 +284,15 @@
     }
 
-    /* Delete visual state: */
-    delete m_pVisualState;
-    m_pVisualState = 0;
+    /* Destroy machine-logic if exists: */
+    if (machineLogic())
+    {
+        m_pMachineLogic->cleanup();
+        UIMachineLogic::destroy(m_pMachineLogic);
+    }
 }
 
 void UIMachine::cleanupSession()
 {
-    /* Destroy session UI if necessary: */
+    /* Destroy session UI if exists: */
     if (uisession())
         UISession::destroy(m_pSession);
@@ -352,6 +301,6 @@
 void UIMachine::cleanup()
 {
-    /* Cleanup visual state: */
-    cleanupVisualState();
+    /* Cleanup machine-logic: */
+    cleanupMachineLogic();
 
     /* Cleanup session UI: */
@@ -364,5 +313,5 @@
 void UIMachine::enterInitialVisualState()
 {
-    sltChangeVisualState(m_initialStateType);
+    sltChangeVisualState(m_initialVisualState);
 }
 
Index: /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
===================================================================
--- /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 53040)
+++ /trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 53041)
@@ -31,5 +31,4 @@
 class QWidget;
 class UISession;
-class UIVisualState;
 class UIMachineLogic;
 
@@ -57,8 +56,8 @@
     static UIMachine* instance() { return m_spInstance; }
 
-    /** Returns UI session instance. */
+    /** Returns session UI instance. */
     UISession *uisession() const { return m_pSession; }
-    /** Returns machine-logic reference (if possible). */
-    UIMachineLogic* machineLogic() const;
+    /** Returns machine-logic instance. */
+    UIMachineLogic* machineLogic() const { return m_pMachineLogic; }
     /** Returns active machine-window reference (if possible). */
     QWidget* activeWindow() const;
@@ -86,9 +85,9 @@
     /** Prepare routine: Session stuff. */
     bool prepareSession();
-    /** Prepare routine: Visual state stuff. */
-    void prepareVisualState();
+    /** Prepare routine: Machine-logic stuff. */
+    void prepareMachineLogic();
 
-    /** Cleanup routine: Visual state stuff. */
-    void cleanupVisualState();
+    /** Cleanup routine: Machine-logic stuff. */
+    void cleanupMachineLogic();
     /** Cleanup routine: Session stuff. */
     void cleanupSession();
@@ -96,5 +95,5 @@
     void cleanup();
 
-    /** Moves VM to default (normal) state. */
+    /** Moves VM to initial state. */
     void enterInitialVisualState();
 
@@ -105,10 +104,12 @@
     UISession *m_pSession;
 
-    /** Holds allowed visual state types. */
+    /** Holds allowed visual states. */
     UIVisualStateType m_allowedVisualStates;
-    /** Holds initial visual state type. */
-    UIVisualStateType m_initialStateType;
+    /** Holds initial visual state. */
+    UIVisualStateType m_initialVisualState;
     /** Holds current visual state. */
-    UIVisualState *m_pVisualState;
+    UIVisualStateType m_visualState;
+    /** Holds current machine-logic. */
+    UIMachineLogic *m_pMachineLogic;
 };
 
