Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 98401)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp	(revision 98402)
@@ -108,5 +108,5 @@
 
 /* static */
-UIMachine *UIMachine::m_spInstance = 0;
+UIMachine *UIMachine::s_pInstance = 0;
 
 /* static */
@@ -114,5 +114,5 @@
 {
     /* Make sure machine is not created: */
-    AssertReturn(!m_spInstance, false);
+    AssertReturn(!s_pInstance, false);
 
     /* Restore current snapshot if requested: */
@@ -166,10 +166,10 @@
 {
     /* Make sure machine is not created: */
-    AssertReturn(!m_spInstance, false);
+    AssertReturn(!s_pInstance, false);
 
     /* Create machine UI: */
     new UIMachine;
     /* Make sure it's prepared: */
-    if (!m_spInstance->prepare())
+    if (!s_pInstance->prepare())
     {
         /* Destroy machine UI otherwise: */
@@ -186,10 +186,10 @@
 {
     /* Make sure machine is created: */
-    if (!m_spInstance)
+    if (!s_pInstance)
         return;
 
     /* Protect versus recursive call: */
-    UIMachine *pInstance = m_spInstance;
-    m_spInstance = 0;
+    UIMachine *pInstance = s_pInstance;
+    s_pInstance = 0;
     /* Cleanup machine UI: */
     pInstance->cleanup();
@@ -371,5 +371,5 @@
 {
     /* Create new machine-logic: */
-    UIMachineLogic *pMachineLogic = UIMachineLogic::create(this, m_pSession, visualState);
+    UIMachineLogic *pMachineLogic = UIMachineLogic::create(this, uisession(), visualState);
 
     /* First we have to check if the selected machine-logic is available at all.
@@ -714,10 +714,10 @@
     , m_restrictedCloseActions(MachineCloseAction_Invalid)
 {
-    m_spInstance = this;
+    s_pInstance = this;
 }
 
 UIMachine::~UIMachine()
 {
-    m_spInstance = 0;
+    s_pInstance = 0;
 }
 
@@ -727,9 +727,9 @@
     if (!UISession::create(m_pSession, this))
         return false;
-    AssertPtrReturn(m_pSession, false);
+    AssertPtrReturn(uisession(), false);
 
     /* Cache media data early if necessary: */
     if (uiCommon().agressiveCaching())
-        uiCommon().enumerateMedia(m_pSession->machineMedia());
+        uiCommon().enumerateMedia(uisession()->machineMedia());
 
     /* Prepare stuff: */
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 98401)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h	(revision 98402)
@@ -152,5 +152,5 @@
     static void destroy();
     /** Static instance. */
-    static UIMachine* instance() { return m_spInstance; }
+    static UIMachine *instance() { return s_pInstance; }
 
     /** Returns session UI instance. */
@@ -296,5 +296,5 @@
     /** @} */
 
-    /** @name Close configuration stuff.
+    /** @name Close stuff.
      * @{ */
         /** Returns default close action. */
@@ -318,6 +318,9 @@
     /** @} */
 
-    /** Closes Runtime UI. */
-    void closeRuntimeUI();
+    /** @name Close stuff.
+     * @{ */
+        /** Closes Runtime UI. */
+        void closeRuntimeUI();
+    /** @} */
 
 private slots:
@@ -499,6 +502,6 @@
     /** @} */
 
-    /** Static instance. */
-    static UIMachine* m_spInstance;
+    /** Holds the static instance. */
+    static UIMachine *s_pInstance;
 
     /** Holds the session UI instance. */
@@ -624,5 +627,5 @@
     /** @} */
 
-    /** @name Close configuration stuff.
+    /** @name Close stuff.
      * @{ */
         /** Default close action. */
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 98401)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp	(revision 98402)
@@ -249,48 +249,39 @@
 void UISession::detachUi()
 {
+    /* Manually close Runtime UI: */
+    LogRel(("GUI: Detaching UI..\n"));
+    closeRuntimeUI();
+}
+
+void UISession::saveState()
+{
+    /* Prepare VM to be saved: */
+    if (!prepareToBeSaved())
+        return;
+
     /* Enable 'manual-override',
      * preventing automatic Runtime UI closing: */
     setManualOverrideMode(true);
 
-    /* Manually close Runtime UI: */
-    LogRel(("GUI: Detaching UI..\n"));
-    closeRuntimeUI();
-}
-
-void UISession::saveState()
-{
-    /* Saving state? */
-    bool fSaveState = true;
-
-    /* If VM is not paused, we should pause it first: */
-    if (!isPaused())
-        fSaveState = pause();
-
-    /* Save state: */
-    if (fSaveState)
-    {
-        /* Enable 'manual-override',
-         * preventing automatic Runtime UI closing: */
-        setManualOverrideMode(true);
-
-        /* Now, do the magic: */
-        LogRel(("GUI: Saving VM state..\n"));
-        UINotificationProgressMachineSaveState *pNotification = new UINotificationProgressMachineSaveState(machine());
-        connect(pNotification, &UINotificationProgressMachineSaveState::sigMachineStateSaved,
-                this, &UISession::sltHandleMachineStateSaved);
-        gpNotificationCenter->append(pNotification);
-    }
+    /* Now, do the magic: */
+    LogRel(("GUI: Saving VM state..\n"));
+    UINotificationProgressMachineSaveState *pNotification =
+        new UINotificationProgressMachineSaveState(machine());
+    connect(pNotification, &UINotificationProgressMachineSaveState::sigMachineStateSaved,
+            this, &UISession::sltHandleMachineStateSaved);
+    gpNotificationCenter->append(pNotification);
 }
 
 void UISession::shutdown()
 {
-    /* Warn the user about ACPI is not available if so: */
-    if (!console().GetGuestEnteredACPIMode())
-        return UINotificationMessage::cannotSendACPIToMachine();
-
-    /* Send ACPI shutdown signal if possible: */
+    /* Prepare VM to be shutdowned: */
+    if (!prepareToBeShutdowned())
+        return;
+
+    /* Now, do the magic: */
     LogRel(("GUI: Sending ACPI shutdown signal..\n"));
-    console().PowerButton();
-    if (!console().isOk())
+    CConsole comConsole = console();
+    comConsole.PowerButton();
+    if (!comConsole.isOk())
         UINotificationMessage::cannotACPIShutdownMachine(console());
 }
@@ -305,5 +296,7 @@
     LogRel(("GUI: Powering VM off..\n"));
     UINotificationProgressMachinePowerOff *pNotification =
-        new UINotificationProgressMachinePowerOff(machine(), console(), fIncludingDiscard);
+        new UINotificationProgressMachinePowerOff(machine(),
+                                                  console(),
+                                                  fIncludingDiscard);
     connect(pNotification, &UINotificationProgressMachinePowerOff::sigMachinePoweredOff,
             this, &UISession::sltHandleMachinePoweredOff);
@@ -333,20 +326,20 @@
 bool UISession::isVisualStateAllowed(UIVisualStateType state) const
 {
-    return m_pMachine->isVisualStateAllowed(state);
+    return uimachine()->isVisualStateAllowed(state);
 }
 
 void UISession::changeVisualState(UIVisualStateType visualStateType)
 {
-    m_pMachine->asyncChangeVisualState(visualStateType);
+    uimachine()->asyncChangeVisualState(visualStateType);
 }
 
 void UISession::setRequestedVisualState(UIVisualStateType visualStateType)
 {
-    m_pMachine->setRequestedVisualState(visualStateType);
+    uimachine()->setRequestedVisualState(visualStateType);
 }
 
 UIVisualStateType UISession::requestedVisualState() const
 {
-    return m_pMachine->requestedVisualState();
+    return uimachine()->requestedVisualState();
 }
 
@@ -998,4 +991,18 @@
 }
 
+bool UISession::prepareToBeSaved()
+{
+    return    isPaused()
+           || (isRunning() && pause());
+}
+
+bool UISession::prepareToBeShutdowned()
+{
+    const bool fValidMode = console().GetGuestEnteredACPIMode();
+    if (!fValidMode)
+        UINotificationMessage::cannotSendACPIToMachine();
+    return fValidMode;
+}
+
 void UISession::loadVMSettings()
 {
Index: trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
===================================================================
--- trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h	(revision 98401)
+++ trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h	(revision 98402)
@@ -266,4 +266,9 @@
     CMediumVector machineMedia() const;
 
+    /** Prepares VM to be saved. */
+    bool prepareToBeSaved();
+    /** Returns whether VM can be shutdowned. */
+    bool prepareToBeShutdowned();
+
 public slots:
 
