Index: trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- trunk/src/VBox/Main/include/MachineImpl.h	(revision 52480)
+++ trunk/src/VBox/Main/include/MachineImpl.h	(revision 52481)
@@ -73,5 +73,4 @@
 class HostUSBDevice;
 class StorageController;
-
 class SessionMachine;
 
@@ -1258,52 +1257,4 @@
     RWLockHandle *lockHandle() const;
 
-    // IInternalMachineControl methods
-    STDMETHOD(SetRemoveSavedStateFile)(BOOL aRemove);
-    STDMETHOD(UpdateState)(MachineState_T machineState);
-    STDMETHOD(BeginPowerUp)(IProgress *aProgress);
-    STDMETHOD(EndPowerUp)(LONG iResult);
-    STDMETHOD(BeginPoweringDown)(IProgress **aProgress);
-    STDMETHOD(EndPoweringDown)(LONG aResult, IN_BSTR aErrMsg);
-    STDMETHOD(RunUSBDeviceFilters)(IUSBDevice *aUSBDevice, BOOL *aMatched, ULONG *aMaskedIfs);
-    STDMETHOD(CaptureUSBDevice)(IN_BSTR aId);
-    STDMETHOD(DetachUSBDevice)(IN_BSTR aId, BOOL aDone);
-    STDMETHOD(AutoCaptureUSBDevices)();
-    STDMETHOD(DetachAllUSBDevices)(BOOL aDone);
-    STDMETHOD(OnSessionEnd)(ISession *aSession, IProgress **aProgress);
-    STDMETHOD(BeginSavingState)(IProgress **aProgress, BSTR *aStateFilePath);
-    STDMETHOD(EndSavingState)(LONG aResult, IN_BSTR aErrMsg);
-    STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile);
-    STDMETHOD(BeginTakingSnapshot)(IConsole *aInitiator,
-                                   IN_BSTR aName,
-                                   IN_BSTR aDescription,
-                                   IProgress *aConsoleProgress,
-                                   BOOL fTakingSnapshotOnline,
-                                   BSTR *aStateFilePath);
-    STDMETHOD(EndTakingSnapshot)(BOOL aSuccess);
-    STDMETHOD(DeleteSnapshot)(IConsole *aInitiator, IN_BSTR aStartId,
-                              IN_BSTR aEndID, BOOL fDeleteAllChildren,
-                              MachineState_T *aMachineState, IProgress **aProgress);
-    STDMETHOD(FinishOnlineMergeMedium)();
-    STDMETHOD(RestoreSnapshot)(IConsole *aInitiator,
-                               ISnapshot *aSnapshot,
-                               MachineState_T *aMachineState,
-                               IProgress **aProgress);
-    STDMETHOD(PullGuestProperties)(ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues),
-              ComSafeArrayOut(LONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
-    STDMETHOD(PushGuestProperty)(IN_BSTR aName, IN_BSTR aValue,
-                                  LONG64 aTimestamp, IN_BSTR aFlags);
-    STDMETHOD(LockMedia)();
-    STDMETHOD(UnlockMedia)();
-    STDMETHOD(EjectMedium)(IMediumAttachment *aAttachment,
-                           IMediumAttachment **aNewAttachment);
-    STDMETHOD(ReportVmStatistics)(ULONG aValidStats, ULONG aCpuUser,
-                                  ULONG aCpuKernel, ULONG aCpuIdle,
-                                  ULONG aMemTotal, ULONG aMemFree,
-                                  ULONG aMemBalloon, ULONG aMemShared,
-                                  ULONG aMemCache, ULONG aPageTotal,
-                                  ULONG aAllocVMM, ULONG aFreeVMM,
-                                  ULONG aBalloonedVMM, ULONG aSharedVMM,
-                                  ULONG aVmNetRx, ULONG aVmNetTx);
-
     // public methods only for internal purposes
 
@@ -1350,8 +1301,81 @@
     bool i_hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
 
+    HRESULT i_lockMedia();
+    HRESULT i_unlockMedia();
+
+private:
+
+    // wrapped IInternalMachineControl properties
+
+    // wrapped IInternalMachineControl methods
+    HRESULT setRemoveSavedStateFile(BOOL aRemove);
+    HRESULT updateState(MachineState_T aState);
+    HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
+    HRESULT endPowerUp(LONG aResult);
+    HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
+    HRESULT endPoweringDown(LONG aResult,
+                            const com::Utf8Str &aErrMsg);
+    HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
+                                BOOL *aMatched,
+                                ULONG *aMaskedInterfaces);
+    HRESULT captureUSBDevice(const com::Guid &aId);
+    HRESULT detachUSBDevice(const com::Guid &aId,
+                            BOOL aDone);
+    HRESULT autoCaptureUSBDevices();
+    HRESULT detachAllUSBDevices(BOOL aDone);
+    HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
+                         ComPtr<IProgress> &aProgress);
+    HRESULT beginSavingState(ComPtr<IProgress> &aProgress,
+                             com::Utf8Str &aStateFilePath);
+    HRESULT endSavingState(LONG aResult,
+                           const com::Utf8Str &aErrMsg);
+    HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
+    HRESULT beginTakingSnapshot(const ComPtr<IConsole> &aInitiator,
+                                const com::Utf8Str &aName,
+                                const com::Utf8Str &aDescription,
+                                const ComPtr<IProgress> &aConsoleProgress,
+                                BOOL aFTakingSnapshotOnline,
+                                com::Utf8Str &aStateFilePath);
+    HRESULT endTakingSnapshot(BOOL aSuccess);
+    HRESULT deleteSnapshot(const ComPtr<IConsole> &aInitiator,
+                           const com::Guid &aStartId,
+                           const com::Guid &aEndId,
+                           BOOL aDeleteAllChildren,
+                           MachineState_T *aMachineState,
+                           ComPtr<IProgress> &aProgress);
+    HRESULT finishOnlineMergeMedium();
+    HRESULT restoreSnapshot(const ComPtr<IConsole> &aInitiator,
+                            const ComPtr<ISnapshot> &aSnapshot,
+                            MachineState_T *aMachineState,
+                            ComPtr<IProgress> &aProgress);
+    HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
+                                std::vector<com::Utf8Str> &aValues,
+                                std::vector<LONG64> &aTimestamps,
+                                std::vector<com::Utf8Str> &aFlags);
+    HRESULT pushGuestProperty(const com::Utf8Str &aName,
+                              const com::Utf8Str &aValue,
+                              LONG64 aTimestamp,
+                              const com::Utf8Str &aFlags);
     HRESULT lockMedia();
     HRESULT unlockMedia();
-
-private:
+    HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
+                        ComPtr<IMediumAttachment> &aNewAttachment);
+    HRESULT reportVmStatistics(ULONG aValidStats,
+                               ULONG aCpuUser,
+                               ULONG aCpuKernel,
+                               ULONG aCpuIdle,
+                               ULONG aMemTotal,
+                               ULONG aMemFree,
+                               ULONG aMemBalloon,
+                               ULONG aMemShared,
+                               ULONG aMemCache,
+                               ULONG aPagedTotal,
+                               ULONG aMemAllocTotal,
+                               ULONG aMemFreeTotal,
+                               ULONG aMemBalloonTotal,
+                               ULONG aMemSharedTotal,
+                               ULONG aVmNetRx,
+                               ULONG aVmNetTx);
+
 
     struct ConsoleTaskData
@@ -1381,5 +1405,5 @@
     friend struct RestoreSnapshotTask;
 
-    HRESULT endSavingState(HRESULT aRC, const Utf8Str &aErrMsg);
+    HRESULT i_endSavingState(HRESULT aRC, const Utf8Str &aErrMsg);
     void i_releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore);
 
Index: trunk/src/VBox/Main/src-client/SessionImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-client/SessionImpl.cpp	(revision 52480)
+++ trunk/src/VBox/Main/src-client/SessionImpl.cpp	(revision 52481)
@@ -269,10 +269,10 @@
 #ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
 HRESULT Session::assignMachine(const ComPtr<IMachine> &aMachine,
-                          LockType_T aLockType,
-                          const com::Utf8Str &aTokenId)
+                               LockType_T aLockType,
+                               const com::Utf8Str &aTokenId)
 #else
 HRESULT Session::assignMachine(const ComPtr<IMachine> &aMachine,
-                          LockType_T aLockType,
-                          const ComPtr<IToken> &aToken)
+                               LockType_T aLockType,
+                               const ComPtr<IToken> &aToken)
 #endif /* !VBOX_WITH_GENERIC_SESSION_WATCHER */
 {
Index: trunk/src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 52480)
+++ trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 52481)
@@ -1861,5 +1861,5 @@
 {
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    
+
     aVideoCaptureOptions = mHWData->mVideoCaptureOptions;
     return S_OK;
@@ -7207,5 +7207,6 @@
  *  Returns the full path to the machine's log file for an given index.
  */
-Utf8Str Machine::i_queryLogFilename(ULONG idx) /** @todo r=bird: Misnamed. Should be i_getLogFilename as it cannot fail. See VBox-CodingGuidelines.cpp, Compulsory seciont, line 79. */
+Utf8Str Machine::i_queryLogFilename(ULONG idx) /** @todo r=bird: Misnamed. Should be i_getLogFilename as it cannot fail.
+                                                   See VBox-CodingGuidelines.cpp, Compulsory seciont, line 79. */
 {
     Utf8Str logFolder;
@@ -7412,5 +7413,6 @@
             Utf8Str strStartupLogDir = strStartupLogFile;
             strStartupLogDir.stripFilename();
-            RTDirCreateFullPath(strStartupLogDir.c_str(), 0755); /** @todo add a variant for creating the path to a file without stripping the file. */
+            RTDirCreateFullPath(strStartupLogDir.c_str(), 0755); /** @todo add a variant for creating the path to a
+                                                                     file without stripping the file. */
         }
         strSupStartLogArg.append(strStartupLogFile);
@@ -10869,5 +10871,5 @@
                 {
                     alock.release();
-                    rc = mData->mSession.mMachine->lockMedia();
+                    rc = mData->mSession.mMachine->i_lockMedia();
                     alock.acquire();
                     if (FAILED(rc))
@@ -12548,12 +12550,12 @@
  *  Passes collected guest statistics to performance collector object
  */
-STDMETHODIMP SessionMachine::ReportVmStatistics(ULONG aValidStats, ULONG aCpuUser,
-                                                ULONG aCpuKernel, ULONG aCpuIdle,
-                                                ULONG aMemTotal, ULONG aMemFree,
-                                                ULONG aMemBalloon, ULONG aMemShared,
-                                                ULONG aMemCache, ULONG aPageTotal,
-                                                ULONG aAllocVMM, ULONG aFreeVMM,
-                                                ULONG aBalloonedVMM, ULONG aSharedVMM,
-                                                ULONG aVmNetRx, ULONG aVmNetTx)
+HRESULT SessionMachine::reportVmStatistics(ULONG aValidStats, ULONG aCpuUser,
+                                           ULONG aCpuKernel, ULONG aCpuIdle,
+                                           ULONG aMemTotal, ULONG aMemFree,
+                                           ULONG aMemBalloon, ULONG aMemShared,
+                                           ULONG aMemCache, ULONG aPageTotal,
+                                           ULONG aAllocVMM, ULONG aFreeVMM,
+                                           ULONG aBalloonedVMM, ULONG aSharedVMM,
+                                           ULONG aVmNetRx, ULONG aVmNetTx)
 {
 #ifdef VBOX_WITH_RESOURCE_USAGE_API
@@ -12589,9 +12591,6 @@
  *  @note Locks this object for writing.
  */
-STDMETHODIMP SessionMachine::SetRemoveSavedStateFile(BOOL aRemove)
-{
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
-
+HRESULT SessionMachine::setRemoveSavedStateFile(BOOL aRemove)
+{
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
@@ -12604,7 +12603,7 @@
  *  @note Locks the same as #i_setMachineState() does.
  */
-STDMETHODIMP SessionMachine::UpdateState(MachineState_T aMachineState)
-{
-    return i_setMachineState(aMachineState);
+HRESULT SessionMachine::updateState(MachineState_T aState)
+{
+    return i_setMachineState(aState);
 }
 
@@ -12612,9 +12611,9 @@
  *  @note Locks this object for writing.
  */
-STDMETHODIMP SessionMachine::BeginPowerUp(IProgress *aProgress)
-{
-    LogFlowThisFunc(("aProgress=%p\n", aProgress));
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
+HRESULT SessionMachine::beginPowerUp(const ComPtr<IProgress> &aProgress)
+{
+    IProgress* pProgress(aProgress);
+
+    LogFlowThisFunc(("aProgress=%p\n", pProgress));
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -12624,5 +12623,5 @@
 
     if (!mData->mSession.mProgress.isNull())
-        mData->mSession.mProgress->setOtherProgressObject(aProgress);
+        mData->mSession.mProgress->setOtherProgressObject(pProgress);
 
     /* If we didn't reference the NAT network service yet, add a reference to
@@ -12664,9 +12663,6 @@
  *  @note Locks this object for writing.
  */
-STDMETHODIMP SessionMachine::EndPowerUp(LONG iResult)
-{
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
-
+HRESULT SessionMachine::endPowerUp(LONG aResult)
+{
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
@@ -12677,9 +12673,9 @@
     if (mData->mSession.mProgress)
     {
-        mData->mSession.mProgress->notifyComplete((HRESULT)iResult);
+        mData->mSession.mProgress->notifyComplete((HRESULT)aResult);
         mData->mSession.mProgress.setNull();
     }
 
-    if (SUCCEEDED((HRESULT)iResult))
+    if (SUCCEEDED((HRESULT)aResult))
     {
 #ifdef VBOX_WITH_RESOURCE_USAGE_API
@@ -12698,10 +12694,7 @@
  *  @note Locks this object for writing.
  */
-STDMETHODIMP SessionMachine::BeginPoweringDown(IProgress **aProgress)
+HRESULT SessionMachine::beginPoweringDown(ComPtr<IProgress> &aProgress)
 {
     LogFlowThisFuncEnter();
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -12725,5 +12718,5 @@
     i_setMachineState(MachineState_Stopping);
 
-    pProgress.queryInterfaceTo(aProgress);
+    pProgress.queryInterfaceTo(aProgress.asOutParam());
 
     return S_OK;
@@ -12733,15 +12726,13 @@
  *  @note Locks this object for writing.
  */
-STDMETHODIMP SessionMachine::EndPoweringDown(LONG iResult, IN_BSTR aErrMsg)
+HRESULT SessionMachine::endPoweringDown(LONG aResult,
+                                        const com::Utf8Str &aErrMsg)
 {
     LogFlowThisFuncEnter();
 
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
-
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    AssertReturn(    (   (SUCCEEDED(iResult) && mData->mMachineState == MachineState_PoweredOff)
-                      || (FAILED(iResult) && mData->mMachineState == MachineState_Stopping))
+    AssertReturn(    (   (SUCCEEDED(aResult) && mData->mMachineState == MachineState_PoweredOff)
+                      || (FAILED(aResult) && mData->mMachineState == MachineState_Stopping))
                   && mConsoleTaskData.mLastState != MachineState_Null,
                  E_FAIL);
@@ -12753,21 +12744,20 @@
      * MachineState_PoweredOff, so no need to do anything.
      */
-    if (FAILED(iResult))
+    if (FAILED(aResult))
         i_setMachineState(mConsoleTaskData.mLastState);
 
     /* notify the progress object about operation completion */
     Assert(mConsoleTaskData.mProgress);
-    if (SUCCEEDED(iResult))
+    if (SUCCEEDED(aResult))
         mConsoleTaskData.mProgress->i_notifyComplete(S_OK);
     else
     {
-        Utf8Str strErrMsg(aErrMsg);
-        if (strErrMsg.length())
-            mConsoleTaskData.mProgress->i_notifyComplete(iResult,
+        if (aErrMsg.length())
+            mConsoleTaskData.mProgress->i_notifyComplete(aResult,
                                                          COM_IIDOF(ISession),
                                                          getComponentName(),
-                                                         strErrMsg.c_str());
+                                                         aErrMsg.c_str());
         else
-            mConsoleTaskData.mProgress->i_notifyComplete(iResult);
+            mConsoleTaskData.mProgress->i_notifyComplete(aResult);
     }
 
@@ -12787,18 +12777,15 @@
  *  @note Locks the same as USBController::hasMatchingFilter() does.
  */
-STDMETHODIMP SessionMachine::RunUSBDeviceFilters(IUSBDevice *aUSBDevice,
-                                                 BOOL *aMatched,
-                                                 ULONG *aMaskedIfs)
+HRESULT SessionMachine::runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
+                                            BOOL  *aMatched,
+                                            ULONG *aMaskedInterfaces)
 {
     LogFlowThisFunc(("\n"));
 
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
-
 #ifdef VBOX_WITH_USB
-    *aMatched = mUSBDeviceFilters->i_hasMatchingFilter(aUSBDevice, aMaskedIfs);
+    *aMatched = mUSBDeviceFilters->i_hasMatchingFilter(aDevice, aMaskedInterfaces);
 #else
-    NOREF(aUSBDevice);
-    NOREF(aMaskedIfs);
+    NOREF(aDevice);
+    NOREF(aMaskedInterfaces);
     *aMatched = FALSE;
 #endif
@@ -12810,10 +12797,7 @@
  *  @note Locks the same as Host::captureUSBDevice() does.
  */
-STDMETHODIMP SessionMachine::CaptureUSBDevice(IN_BSTR aId)
+HRESULT SessionMachine::captureUSBDevice(const com::Guid &aId)
 {
     LogFlowThisFunc(("\n"));
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturnRC(autoCaller.rc());
 
 #ifdef VBOX_WITH_USB
@@ -12825,5 +12809,5 @@
     USBProxyService *service = mParent->i_host()->i_usbProxyService();
     AssertReturn(service, E_FAIL);
-    return service->captureDeviceForVM(this, Guid(aId).ref());
+    return service->captureDeviceForVM(this, aId.ref());
 #else
     NOREF(aId);
@@ -12835,15 +12819,13 @@
  *  @note Locks the same as Host::detachUSBDevice() does.
  */
-STDMETHODIMP SessionMachine::DetachUSBDevice(IN_BSTR aId, BOOL aDone)
+HRESULT SessionMachine::detachUSBDevice(const com::Guid &aId,
+                                        BOOL aDone)
 {
     LogFlowThisFunc(("\n"));
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
 #ifdef VBOX_WITH_USB
     USBProxyService *service = mParent->i_host()->i_usbProxyService();
     AssertReturn(service, E_FAIL);
-    return service->detachDeviceFromVM(this, Guid(aId).ref(), !!aDone);
+    return service->detachDeviceFromVM(this, aId.ref(), !!aDone);
 #else
     NOREF(aId);
@@ -12861,10 +12843,7 @@
  *  @note Locks what called methods lock.
  */
-STDMETHODIMP SessionMachine::AutoCaptureUSBDevices()
+HRESULT SessionMachine::autoCaptureUSBDevices()
 {
     LogFlowThisFunc(("\n"));
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
 #ifdef VBOX_WITH_USB
@@ -12891,10 +12870,7 @@
  *  @note Locks what called methods lock.
  */
-STDMETHODIMP SessionMachine::DetachAllUSBDevices(BOOL aDone)
+HRESULT SessionMachine::detachAllUSBDevices(BOOL aDone)
 {
     LogFlowThisFunc(("\n"));
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
 #ifdef VBOX_WITH_USB
@@ -12915,13 +12891,8 @@
  *  @note Locks this object for writing.
  */
-STDMETHODIMP SessionMachine::OnSessionEnd(ISession *aSession,
-                                          IProgress **aProgress)
+HRESULT SessionMachine::onSessionEnd(const ComPtr<ISession> &aSession,
+                                     ComPtr<IProgress> &aProgress)
 {
     LogFlowThisFuncEnter();
-
-    AssertReturn(aSession, E_INVALIDARG);
-    AssertReturn(aProgress, E_INVALIDARG);
-
-    AutoCaller autoCaller(this);
 
     LogFlowThisFunc(("callerstate=%d\n", getObjectState().getState()));
@@ -12930,5 +12901,4 @@
      *  informs us it is closed right after we've been uninitialized -- it's ok.
      */
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
     /* get IInternalSessionControl interface */
@@ -12943,5 +12913,6 @@
     if (control == mData->mSession.mDirectControl)
     {
-        ComAssertRet(aProgress, E_POINTER);
+        IProgress *pProgress = aProgress;
+        ComAssertRet(pProgress, E_POINTER);
 
         /* The direct session is being normally closed by the client process
@@ -12980,5 +12951,5 @@
                        Bstr(tr("Closing session")).raw(),
                        FALSE /* aCancelable */);
-        progress.queryInterfaceTo(aProgress);
+        progress.queryInterfaceTo(aProgress.asOutParam());
         mData->mSession.mProgress = progress;
     }
@@ -13012,13 +12983,8 @@
  *  @note Locks this object for writing.
  */
-STDMETHODIMP SessionMachine::BeginSavingState(IProgress **aProgress, BSTR *aStateFilePath)
+HRESULT SessionMachine::beginSavingState(ComPtr<IProgress> &aProgress,
+                                         com::Utf8Str &aStateFilePath)
 {
     LogFlowThisFuncEnter();
-
-    CheckComArgOutPointerValid(aProgress);
-    CheckComArgOutPointerValid(aStateFilePath);
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -13037,12 +13003,11 @@
                     FALSE /* aCancelable */);
 
-    Utf8Str strStateFilePath;
     /* stateFilePath is null when the machine is not running */
     if (mData->mMachineState == MachineState_Paused)
-        i_composeSavedStateFilename(strStateFilePath);
+        i_composeSavedStateFilename(aStateFilePath);
 
     /* fill in the console task data */
     mConsoleTaskData.mLastState = mData->mMachineState;
-    mConsoleTaskData.strStateFilePath = strStateFilePath;
+    mConsoleTaskData.strStateFilePath = aStateFilePath;
     mConsoleTaskData.mProgress = pProgress;
 
@@ -13050,6 +13015,5 @@
     i_setMachineState(MachineState_Saving);
 
-    strStateFilePath.cloneTo(aStateFilePath);
-    pProgress.queryInterfaceTo(aProgress);
+    pProgress.queryInterfaceTo(aProgress.asOutParam());
 
     return S_OK;
@@ -13059,16 +13023,14 @@
  *  @note Locks mParent + this object for writing.
  */
-STDMETHODIMP SessionMachine::EndSavingState(LONG iResult, IN_BSTR aErrMsg)
+HRESULT SessionMachine::endSavingState(LONG aResult,
+                                       const com::Utf8Str &aErrMsg)
 {
     LogFlowThisFunc(("\n"));
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
     /* endSavingState() need mParent lock */
     AutoMultiWriteLock2 alock(mParent, this COMMA_LOCKVAL_SRC_POS);
 
-    AssertReturn(    (   (SUCCEEDED(iResult) && mData->mMachineState == MachineState_Saved)
-                      || (FAILED(iResult) && mData->mMachineState == MachineState_Saving))
+    AssertReturn(    (   (SUCCEEDED(aResult) && mData->mMachineState == MachineState_Saved)
+                      || (FAILED(aResult) && mData->mMachineState == MachineState_Saving))
                   && mConsoleTaskData.mLastState != MachineState_Null
                   && !mConsoleTaskData.strStateFilePath.isEmpty(),
@@ -13081,8 +13043,8 @@
      * MachineState_Saved, so no need to do anything.
      */
-    if (FAILED(iResult))
+    if (FAILED(aResult))
         i_setMachineState(mConsoleTaskData.mLastState);
 
-    return endSavingState(iResult, aErrMsg);
+    return i_endSavingState(aResult, aErrMsg);
 }
 
@@ -13090,12 +13052,7 @@
  *  @note Locks this object for writing.
  */
-STDMETHODIMP SessionMachine::AdoptSavedState(IN_BSTR aSavedStateFile)
+HRESULT SessionMachine::adoptSavedState(const com::Utf8Str &aSavedStateFile)
 {
     LogFlowThisFunc(("\n"));
-
-    CheckComArgStrNotEmptyOrNull(aSavedStateFile);
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -13106,10 +13063,10 @@
                  , E_FAIL); /** @todo setError. */
 
-    Utf8Str stateFilePathFull = aSavedStateFile;
-    int vrc = i_calculateFullPath(stateFilePathFull, stateFilePathFull);
+    com::Utf8Str stateFilePathFull = aSavedStateFile;
+    int vrc = i_calculateFullPath(aSavedStateFile, stateFilePathFull);
     if (RT_FAILURE(vrc))
         return setError(VBOX_E_FILE_ERROR,
-                        tr("Invalid saved state file path '%ls' (%Rrc)"),
-                        aSavedStateFile,
+                        tr("Invalid saved state file path '%s' (%Rrc)"),
+                        stateFilePathFull.c_str(),
                         vrc);
 
@@ -13122,8 +13079,8 @@
 }
 
-STDMETHODIMP SessionMachine::PullGuestProperties(ComSafeArrayOut(BSTR, aNames),
-                                                 ComSafeArrayOut(BSTR, aValues),
-                                                 ComSafeArrayOut(LONG64, aTimestamps),
-                                                 ComSafeArrayOut(BSTR, aFlags))
+HRESULT SessionMachine::pullGuestProperties(std::vector<com::Utf8Str> &aNames,
+                                            std::vector<com::Utf8Str> &aValues,
+                                            std::vector<LONG64>       &aTimestamps,
+                                            std::vector<com::Utf8Str> &aFlags)
 {
     LogFlowThisFunc(("\n"));
@@ -13132,42 +13089,31 @@
     using namespace guestProp;
 
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
-
     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    CheckComArgOutSafeArrayPointerValid(aNames);
-    CheckComArgOutSafeArrayPointerValid(aValues);
-    CheckComArgOutSafeArrayPointerValid(aTimestamps);
-    CheckComArgOutSafeArrayPointerValid(aFlags);
-
     size_t cEntries = mHWData->mGuestProperties.size();
-    com::SafeArray<BSTR> names(cEntries);
-    com::SafeArray<BSTR> values(cEntries);
-    com::SafeArray<LONG64> timestamps(cEntries);
-    com::SafeArray<BSTR> flags(cEntries);
-    unsigned i = 0;
+    aNames.resize(cEntries);
+    aValues.resize(cEntries);
+    aTimestamps.resize(cEntries);
+    aFlags.resize(cEntries);
+
+    size_t  i = 0;
     for (HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.begin();
          it != mHWData->mGuestProperties.end();
-         ++it)
+         ++it, ++i)
     {
         char szFlags[MAX_FLAGS_LEN + 1];
-        it->first.cloneTo(&names[i]);
-        it->second.strValue.cloneTo(&values[i]);
-        timestamps[i] = it->second.mTimestamp;
+        aNames[i] = it->first;
+        aValues[i] = it->second.strValue;
+        aTimestamps[i] = it->second.mTimestamp;
+
         /* If it is NULL, keep it NULL. */
         if (it->second.mFlags)
         {
             writeFlags(it->second.mFlags, szFlags);
-            Bstr(szFlags).cloneTo(&flags[i]);
+            aFlags[i] = szFlags;
         }
         else
-            flags[i] = NULL;
-        ++i;
-    }
-    names.detachTo(ComSafeArrayOutArg(aNames));
-    values.detachTo(ComSafeArrayOutArg(aValues));
-    timestamps.detachTo(ComSafeArrayOutArg(aTimestamps));
-    flags.detachTo(ComSafeArrayOutArg(aFlags));
+            aFlags[i] = "";
+    }
     return S_OK;
 #else
@@ -13176,8 +13122,8 @@
 }
 
-STDMETHODIMP SessionMachine::PushGuestProperty(IN_BSTR aName,
-                                               IN_BSTR aValue,
-                                               LONG64  aTimestamp,
-                                               IN_BSTR aFlags)
+HRESULT SessionMachine::pushGuestProperty(const  com::Utf8Str &aName,
+                                          const  com::Utf8Str &aValue,
+                                                 LONG64       aTimestamp,
+                                          const  com::Utf8Str &aFlags)
 {
     LogFlowThisFunc(("\n"));
@@ -13185,8 +13131,4 @@
 #ifdef VBOX_WITH_GUEST_PROPS
     using namespace guestProp;
-
-    CheckComArgStrNotEmptyOrNull(aName);
-    CheckComArgNotNull(aValue);
-    CheckComArgNotNull(aFlags);
 
     try
@@ -13195,10 +13137,8 @@
          * Convert input up front.
          */
-        Utf8Str  utf8Name(aName);
         uint32_t fFlags = NILFLAG;
-        if (aFlags)
-        {
-            Utf8Str utf8Flags(aFlags);
-            int vrc = validateFlags(utf8Flags.c_str(), &fFlags);
+        if (aFlags.length())
+        {
+            int vrc = validateFlags(aFlags.c_str(), &fFlags);
             AssertRCReturn(vrc, E_INVALIDARG);
         }
@@ -13207,6 +13147,4 @@
          * Now grab the object lock, validate the state and do the update.
          */
-        AutoCaller autoCaller(this);
-        if (FAILED(autoCaller.rc())) return autoCaller.rc();
 
         AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -13233,6 +13171,6 @@
         mHWData.backup();
 
-        bool fDelete = !RT_VALID_PTR(aValue) || *(aValue) == '\0';
-        HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.find(utf8Name);
+        bool fDelete = !aValue.length();
+        HWData::GuestPropertyMap::iterator it = mHWData->mGuestProperties.find(aName);
         if (it != mHWData->mGuestProperties.end())
         {
@@ -13255,5 +13193,5 @@
             prop.mFlags     = fFlags;
 
-            mHWData->mGuestProperties[utf8Name] = prop;
+            mHWData->mGuestProperties[aName] = prop;
             mData->mGuestPropertiesModified = TRUE;
         }
@@ -13265,5 +13203,5 @@
              || RTStrSimplePatternMultiMatch(mHWData->mGuestPropertyNotificationPatterns.c_str(),
                                              RTSTR_MAX,
-                                             utf8Name.c_str(),
+                                             aName.c_str(),
                                              RTSTR_MAX, NULL)
            )
@@ -13272,7 +13210,7 @@
 
             mParent->i_onGuestPropertyChange(mData->mUuid,
-                                             aName,
-                                             aValue,
-                                             aFlags);
+                                             Bstr(aName).raw(),
+                                             Bstr(aValue).raw(),
+                                             Bstr(aFlags).raw());
         }
     }
@@ -13287,9 +13225,7 @@
 }
 
-STDMETHODIMP SessionMachine::LockMedia()
-{
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
-
+
+HRESULT SessionMachine::lockMedia()
+{
     AutoMultiWriteLock2 alock(this->lockHandle(),
                               &mParent->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
@@ -13301,22 +13237,16 @@
     clearError();
     alock.release();
-    return lockMedia();
-}
-
-STDMETHODIMP SessionMachine::UnlockMedia()
-{
-    HRESULT hrc = unlockMedia();
+    return i_lockMedia();
+}
+
+HRESULT SessionMachine::unlockMedia()
+{
+    HRESULT hrc = i_unlockMedia();
     return hrc;
 }
 
-STDMETHODIMP SessionMachine::EjectMedium(IMediumAttachment *aAttachment,
-                                         IMediumAttachment **aNewAttachment)
-{
-    CheckComArgNotNull(aAttachment);
-    CheckComArgOutPointerValid(aNewAttachment);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
+HRESULT SessionMachine::ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
+                                    ComPtr<IMediumAttachment> &aNewAttachment)
+{
     // request the host lock first, since might be calling Host methods for getting host drives;
     // next, protect the media tree all the while we're in here, as well as our member variables
@@ -13325,5 +13255,6 @@
                                   &mParent->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS);
 
-    ComObjPtr<MediumAttachment> pAttach = static_cast<MediumAttachment *>(aAttachment);
+    IMediumAttachment *iAttach = aAttachment;
+    ComObjPtr<MediumAttachment> pAttach = static_cast<MediumAttachment *>(iAttach);
 
     Bstr ctrlName;
@@ -13332,7 +13263,4 @@
     bool fTempEject;
     {
-        AutoCaller autoAttachCaller(this);
-        if (FAILED(autoAttachCaller.rc())) return autoAttachCaller.rc();
-
         AutoReadLock attLock(pAttach COMMA_LOCKVAL_SRC_POS);
 
@@ -13384,5 +13312,5 @@
     }
 
-    pAttach.queryInterfaceTo(aNewAttachment);
+    pAttach.queryInterfaceTo(aNewAttachment.asOutParam());
 
     return S_OK;
@@ -13975,5 +13903,5 @@
  *  @note Locks mParent + this objects for writing.
  */
-HRESULT SessionMachine::endSavingState(HRESULT aRc, const Utf8Str &aErrMsg)
+HRESULT SessionMachine::i_endSavingState(HRESULT aRc, const Utf8Str &aErrMsg)
 {
     LogFlowThisFuncEnter();
@@ -14074,5 +14002,5 @@
  * no more needed.
  */
-HRESULT SessionMachine::lockMedia()
+HRESULT SessionMachine::i_lockMedia()
 {
     AutoCaller autoCaller(this);
@@ -14151,5 +14079,5 @@
  * Undoes the locks made by by #lockMedia().
  */
-HRESULT SessionMachine::unlockMedia()
+HRESULT SessionMachine::i_unlockMedia()
 {
     AutoCaller autoCaller(this);
Index: trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 52480)
+++ trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 52481)
@@ -1394,20 +1394,14 @@
  * @return
  */
-STDMETHODIMP SessionMachine::BeginTakingSnapshot(IConsole *aInitiator,
-                                                 IN_BSTR aName,
-                                                 IN_BSTR aDescription,
-                                                 IProgress *aConsoleProgress,
-                                                 BOOL fTakingSnapshotOnline,
-                                                 BSTR *aStateFilePath)
+HRESULT SessionMachine::beginTakingSnapshot(const ComPtr<IConsole> &aInitiator,
+                                            const com::Utf8Str &aName,
+                                            const com::Utf8Str &aDescription,
+                                            const ComPtr<IProgress> &aConsoleProgress,
+                                            BOOL  aFTakingSnapshotOnline,
+                                            com::Utf8Str &aStateFilePath)
 {
     LogFlowThisFuncEnter();
 
-    AssertReturn(aInitiator && aName, E_INVALIDARG);
-    AssertReturn(aStateFilePath, E_POINTER);
-
-    LogFlowThisFunc(("aName='%ls' fTakingSnapshotOnline=%RTbool\n", aName, fTakingSnapshotOnline));
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
+    LogFlowThisFunc(("aName='%s' aFTakingSnapshotOnline=%RTbool\n", aName.c_str(), aFTakingSnapshotOnline));
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -1428,5 +1422,5 @@
     }
 
-    if (    !fTakingSnapshotOnline
+    if (    !aFTakingSnapshotOnline
          && mData->mMachineState != MachineState_Saved
        )
@@ -1444,7 +1438,6 @@
     snapshotId.create();
 
-    Utf8Str strStateFilePath;
     /* stateFilePath is null when the machine is not online nor saved */
-    if (fTakingSnapshotOnline)
+    if (aFTakingSnapshotOnline)
     {
         Bstr value;
@@ -1452,17 +1445,15 @@
                                   value.asOutParam());
         if (FAILED(rc) || value != "1")
-        {
             // creating a new online snapshot: we need a fresh saved state file
-            i_composeSavedStateFilename(strStateFilePath);
-        }
+            i_composeSavedStateFilename(aStateFilePath);
     }
     else if (mData->mMachineState == MachineState_Saved)
         // taking an online snapshot from machine in "saved" state: then use existing state file
-        strStateFilePath = mSSData->strStateFilePath;
-
-    if (strStateFilePath.isNotEmpty())
+        aStateFilePath = mSSData->strStateFilePath;
+
+    if (aStateFilePath.isNotEmpty())
     {
         // ensure the directory for the saved state file exists
-        HRESULT rc = VirtualBox::i_ensureFilePathExists(strStateFilePath, true /* fCreate */);
+        HRESULT rc = VirtualBox::i_ensureFilePathExists(aStateFilePath, true /* fCreate */);
         if (FAILED(rc)) return rc;
     }
@@ -1471,5 +1462,5 @@
     ComObjPtr<SnapshotMachine> snapshotMachine;
     snapshotMachine.createObject();
-    HRESULT rc = snapshotMachine->init(this, snapshotId.ref(), strStateFilePath);
+    HRESULT rc = snapshotMachine->init(this, snapshotId.ref(), aStateFilePath);
     AssertComRCReturn(rc, rc);
 
@@ -1490,4 +1481,5 @@
     mConsoleTaskData.mLastState = mData->mMachineState;
     mConsoleTaskData.mSnapshot = pSnapshot;
+
     /// @todo in the long run the progress object should be moved to
     // VBoxSVC to avoid trouble with monitoring the progress object state
@@ -1498,5 +1490,5 @@
     {
         LogFlowThisFunc(("Creating differencing hard disks (online=%d)...\n",
-                         fTakingSnapshotOnline));
+                         aFTakingSnapshotOnline));
 
         // backup the media data so we can recover if things goes wrong along the day;
@@ -1515,5 +1507,5 @@
         rc = i_createImplicitDiffs(aConsoleProgress,
                                    1,            // operation weight; must be the same as in Console::TakeSnapshot()
-                                   !!fTakingSnapshotOnline);
+                                   !!aFTakingSnapshotOnline);
         if (FAILED(rc))
             throw rc;
@@ -1543,8 +1535,6 @@
     }
 
-    if (fTakingSnapshotOnline && SUCCEEDED(rc))
-        strStateFilePath.cloneTo(aStateFilePath);
-    else
-        *aStateFilePath = NULL;
+    if (!(aFTakingSnapshotOnline && SUCCEEDED(rc)))
+        aStateFilePath = "";
 
     LogFlowThisFunc(("LEAVE - %Rhrc [%s]\n", rc, Global::stringifyMachineState(mData->mMachineState) ));
@@ -1566,10 +1556,7 @@
  * @return
  */
-STDMETHODIMP SessionMachine::EndTakingSnapshot(BOOL aSuccess)
+HRESULT SessionMachine::endTakingSnapshot(BOOL aSuccess)
 {
     LogFlowThisFunc(("\n"));
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
 
     AutoWriteLock machineLock(this COMMA_LOCKVAL_SRC_POS);
@@ -1693,16 +1680,10 @@
  * @return
  */
-STDMETHODIMP SessionMachine::RestoreSnapshot(IConsole *aInitiator,
-                                             ISnapshot *aSnapshot,
-                                             MachineState_T *aMachineState,
-                                             IProgress **aProgress)
+HRESULT SessionMachine::restoreSnapshot(const ComPtr<IConsole> &aInitiator,
+                                        const ComPtr<ISnapshot> &aSnapshot,
+                                        MachineState_T *aMachineState,
+                                        ComPtr<IProgress> &aProgress)
 {
     LogFlowThisFuncEnter();
-
-    AssertReturn(aInitiator, E_INVALIDARG);
-    AssertReturn(aSnapshot && aMachineState && aProgress, E_POINTER);
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -1712,5 +1693,6 @@
                  E_FAIL);
 
-    ComObjPtr<Snapshot> pSnapshot(static_cast<Snapshot*>(aSnapshot));
+    ISnapshot* iSnapshot = aSnapshot;
+    ComObjPtr<Snapshot>pSnapshot(static_cast<Snapshot*>(iSnapshot));
     ComObjPtr<SnapshotMachine> pSnapMachine = pSnapshot->i_getSnapshotMachine();
 
@@ -1769,5 +1751,5 @@
 
     /* return the progress to the caller */
-    pProgress.queryInterfaceTo(aProgress);
+    pProgress.queryInterfaceTo(aProgress.asOutParam());
 
     /* return the new state to the caller */
@@ -2055,5 +2037,5 @@
 
 /**
- * Implementation for IInternalMachineControl::DeleteSnapshot().
+ * Implementation for IInternalMachineControl::deleteSnapshot().
  *
  * Gets called from Console::DeleteSnapshot(), and that's basically the
@@ -2070,26 +2052,20 @@
  * @note Locks mParent + this + children objects for writing!
  */
-STDMETHODIMP SessionMachine::DeleteSnapshot(IConsole *aInitiator,
-                                            IN_BSTR aStartId,
-                                            IN_BSTR aEndId,
-                                            BOOL fDeleteAllChildren,
-                                            MachineState_T *aMachineState,
-                                            IProgress **aProgress)
+HRESULT SessionMachine::deleteSnapshot(const ComPtr<IConsole> &aInitiator,
+                                       const com::Guid &aStartId,
+                                       const com::Guid &aEndId,
+                                       BOOL aDeleteAllChildren,
+                                       MachineState_T *aMachineState,
+                                       ComPtr<IProgress> &aProgress)
 {
     LogFlowThisFuncEnter();
 
-    Guid startId(aStartId);
-    Guid endId(aEndId);
-
-    AssertReturn(aInitiator && !startId.isZero() && !endId.isZero() && startId.isValid() && endId.isValid(), E_INVALIDARG);
+    AssertReturn(aInitiator && !aStartId.isZero() && !aEndId.isZero() && aStartId.isValid() && aEndId.isValid(), E_INVALIDARG);
 
     AssertReturn(aMachineState && aProgress, E_POINTER);
 
     /** @todo implement the "and all children" and "range" variants */
-    if (fDeleteAllChildren || startId != endId)
+    if (aDeleteAllChildren || aStartId != aEndId)
         ReturnComNotImplemented();
-
-    AutoCaller autoCaller(this);
-    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
 
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
@@ -2108,5 +2084,5 @@
 
     ComObjPtr<Snapshot> pSnapshot;
-    HRESULT rc = i_findSnapshotById(startId, pSnapshot, true /* aSetError */);
+    HRESULT rc = i_findSnapshotById(aStartId, pSnapshot, true /* aSetError */);
     if (FAILED(rc)) return rc;
 
@@ -2226,5 +2202,5 @@
 
     /* return the progress to the caller */
-    pProgress.queryInterfaceTo(aProgress);
+    pProgress.queryInterfaceTo(aProgress.asOutParam());
 
     /* return the new state to the caller */
@@ -3428,5 +3404,5 @@
 
 /**
- * Implementation for IInternalMachineControl::FinishOnlineMergeMedium().
+ * Implementation for IInternalMachineControl::finishOnlineMergeMedium().
  *
  * Gets called after the successful completion of an online merge from
@@ -3437,5 +3413,5 @@
  * can continue with the updated state of the medium chain.
  */
-STDMETHODIMP SessionMachine::FinishOnlineMergeMedium()
+HRESULT SessionMachine::finishOnlineMergeMedium()
 {
     HRESULT rc = S_OK;
