Index: SubWCRev/SubWCRevCOM.cpp
===================================================================
--- SubWCRev/SubWCRevCOM.cpp	(revision 18366)
+++ SubWCRev/SubWCRevCOM.cpp	(working copy)
@@ -563,19 +563,14 @@
 	}
 
 	// Create component.
-	SubWCRev* pA = new (std::nothrow) SubWCRev();
+	ATL::CComPtr<SubWCRev> pA;
+	pA.Attach(new (std::nothrow) SubWCRev());// refcount set to 1 in constructor
 	if (pA == NULL)
 	{
 		return E_OUTOFMEMORY ;
 	}
 
-	// Get the requested interface.
-	HRESULT hr = pA->QueryInterface(iid, ppv) ;
-
-	// Release the IUnknown pointer.
-	// (If QueryInterface failed, component will delete itself.)
-	pA->Release() ;
-	return hr ;
+	return pA->QueryInterface(iid, ppv);
 }
 
 // LockServer
@@ -626,18 +621,14 @@
 	}
 
 	// Create class factory.
-	CFactory* pFactory = new (std::nothrow) CFactory ;  // Reference count set to 1
+	ATL::CComPtr<CFactory> pFactory;
+	pFactory.Attach(new (std::nothrow) CFactory);  // Reference count set to 1
 	// in constructor
 	if (pFactory == NULL)
 	{
 		return E_OUTOFMEMORY ;
 	}
-
-	// Get requested interface.
-	HRESULT hr = pFactory->QueryInterface(iid, ppv) ;
-	pFactory->Release() ;
-
-	return hr ;
+	return pFactory->QueryInterface(iid, ppv) ;
 }
 
 CFactory gClassFactory;
Index: SVN/TSVNPath.cpp
===================================================================
--- SVN/TSVNPath.cpp	(revision 18366)
+++ SVN/TSVNPath.cpp	(working copy)
@@ -320,13 +320,7 @@
 			_tcscpy_s(buf, m_sBackslashPath.GetLength()+2, m_sBackslashPath);
 			buf[m_sBackslashPath.GetLength()] = 0;
 			buf[m_sBackslashPath.GetLength()+1] = 0;
-			SHFILEOPSTRUCT shop = {0};
-			shop.wFunc = FO_DELETE;
-			shop.pFrom = buf;
-			shop.fFlags = FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT|FOF_NO_CONNECTED_ELEMENTS;
-			if (bTrash)
-				shop.fFlags |= FOF_ALLOWUNDO;
-			bRet = (SHFileOperation(&shop) == 0);
+			bRet = CTSVNPathList::DeleteViaShell(buf, bTrash)
 		}
 		else
 		{
@@ -1122,13 +1116,7 @@
 	}
 	sPaths += '\0';
 	sPaths += '\0';
-	SHFILEOPSTRUCT shop = {0};
-	shop.wFunc = FO_DELETE;
-	shop.pFrom = (LPCTSTR)sPaths;
-	shop.fFlags = (bTrash ? FOF_ALLOWUNDO : 0)
-				| FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT|FOF_NO_CONNECTED_ELEMENTS;
-	SHFileOperation(&shop);
-
+	DeleteViaShell((LPCTSTR)sPaths, bTrash); 
 	Clear();
 }
 
@@ -1201,6 +1189,18 @@
 	return targets;
 }
 
+bool CTSVNPathList::DeleteViaShell(LPCTSTR path, bool bTrash)
+{
+	SHFILEOPSTRUCT shop = {0};
+	shop.wFunc = FO_DELETE;
+	shop.pFrom = path;
+	shop.fFlags = FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT|FOF_NO_CONNECTED_ELEMENTS;
+	if (bTrash)
+		shop.fFlags |= FOF_ALLOWUNDO;
+	const bool bRet = (SHFileOperation(&shop) == 0);
+	return bRet;
+}
+
 //////////////////////////////////////////////////////////////////////////
 
 
Index: SVN/TSVNPath.h
===================================================================
--- SVN/TSVNPath.h	(revision 18366)
+++ SVN/TSVNPath.h	(working copy)
@@ -354,6 +354,8 @@
 	/** Convert into the SVN API parameter format */
 	apr_array_header_t * MakePathArray (apr_pool_t *pool) const;
 
+	static bool DeleteViaShell(LPCTSTR path, bool useTrashbin);
+
 private:
 	typedef std::vector<CTSVNPath> PathVector;
 	PathVector m_paths;
@@ -361,5 +363,3 @@
 	// this contains the directory name
 	mutable CTSVNPath m_commonBaseDirectory;
 };
-
-
Index: TortoiseBlame/TortoiseBlame.cpp
===================================================================
--- TortoiseBlame/TortoiseBlame.cpp	(revision 18366)
+++ TortoiseBlame/TortoiseBlame.cpp	(working copy)
@@ -1232,13 +1232,8 @@
 
 void TortoiseBlame::RunCommand(const tstring& command)
 {
-	PROCESS_INFORMATION process;
 	tstring tortoiseProcPath = GetAppDirectory() + _T("TortoiseProc.exe");
-	if(!CCreateProcessHelper::CreateProcess(tortoiseProcPath.c_str(), const_cast<TCHAR*>(command.c_str()), &process))
-		return;
-
-	CloseHandle(process.hThread);
-	CloseHandle(process.hProcess);
+	CCreateProcessHelper::CreateProcessDetached(tortoiseProcPath.c_str(), const_cast<TCHAR*>(command.c_str()));
 }
 
 // Forward declarations of functions included in this code module:
Index: TortoiseMerge/MainFrm.cpp
===================================================================
--- TortoiseMerge/MainFrm.cpp	(revision 18366)
+++ TortoiseMerge/MainFrm.cpp	(working copy)
@@ -2021,13 +2021,8 @@
 
 bool CMainFrame::RunCommand(TCHAR* command)
 {
-	PROCESS_INFORMATION process;
-	if(CCreateProcessHelper::CreateProcess (NULL, command, &process))
-	{
-		CloseHandle(process.hThread);
-		CloseHandle(process.hProcess);
+	if(CCreateProcessHelper::CreateProcessDetached (NULL, command))
 		return true;
-	}
 
 	CFormatMessageWrapper errorDetails;
     MessageBox(errorDetails, _T("TortoiseMerge"), MB_OK | MB_ICONINFORMATION);
Index: TortoiseProc/AppUtils.cpp
===================================================================
--- TortoiseProc/AppUtils.cpp	(revision 18366)
+++ TortoiseProc/AppUtils.cpp	(working copy)
@@ -1159,7 +1159,7 @@
 	{
 		hRes = pPersistFile->Save(pszLinkfile, TRUE);
 	}
-	return (hRes);
+	return hRes;
 }
 
 HRESULT CAppUtils::CreateShortcutToURL(LPCTSTR pszURL, LPCTSTR pszLinkFile)
@@ -1279,13 +1279,12 @@
 
 bool CAppUtils::SetAccProperty(HWND hWnd, MSAAPROPID propid, const CString& text)
 {
-	IAccPropServices * pAccPropSvc = NULL;
-	HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, IID_IAccPropServices, (void **)&pAccPropSvc);
+	ATL::CComPtr<IAccPropServices> pAccPropSvc;
+	HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
 
 	if (hr == S_OK && pAccPropSvc)
 	{
 		pAccPropSvc->SetHwndPropStr(hWnd, (DWORD)OBJID_CLIENT, CHILDID_SELF, propid, text);
-		pAccPropSvc->Release();
 		return true;
 	}
 	return false;
@@ -1293,8 +1292,8 @@
 
 bool CAppUtils::SetAccProperty(HWND hWnd, MSAAPROPID propid, long value)
 {
-	IAccPropServices * pAccPropSvc = NULL;
-	HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, IID_IAccPropServices, (void **)&pAccPropSvc);
+	ATL::CComPtr<IAccPropServices> pAccPropSvc;
+	HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
 
 	if (hr == S_OK && pAccPropSvc)
 	{
@@ -1302,7 +1301,6 @@
 		var.vt = VT_I4;
 		var.intVal = value;
 		pAccPropSvc->SetHwndProp(hWnd, (DWORD)OBJID_CLIENT, CHILDID_SELF, propid, var);
-		pAccPropSvc->Release();
 		return true;
 	}
 	return false;
Index: TortoiseProc/CommitDlg.cpp
===================================================================
--- TortoiseProc/CommitDlg.cpp	(revision 18366)
+++ TortoiseProc/CommitDlg.cpp	(working copy)
@@ -532,26 +532,23 @@
 	INT_PTR nDeleted = arDeleted.GetCount();
 	for (INT_PTR i=0; i<arDeleted.GetCount(); i++)
 	{
-		if (m_ListCtrl.GetCheck(arDeleted.GetAt(i)))
+		if (!m_ListCtrl.GetCheck(arDeleted.GetAt(i)))
+			continue;
+		const CTSVNPath& path = m_ListCtrl.GetListEntry(arDeleted.GetAt(i))->GetPath();
+		if (!path.IsDirectory())
+			continue;
+		//now find all children of this directory
+		for (int j=0; j<arDeleted.GetCount(); j++)
 		{
-			const CTSVNPath& path = m_ListCtrl.GetListEntry(arDeleted.GetAt(i))->GetPath();
-			if (path.IsDirectory())
+			if (i==j)
+				continue;
+			CSVNStatusListCtrl::FileEntry* childEntry = m_ListCtrl.GetListEntry(arDeleted.GetAt(j));
+			if (childEntry->IsChecked())
 			{
-				//now find all children of this directory
-				for (int j=0; j<arDeleted.GetCount(); j++)
+				if (path.IsAncestorOf(childEntry->GetPath()))
 				{
-					if (i!=j)
-					{
-						CSVNStatusListCtrl::FileEntry* childEntry = m_ListCtrl.GetListEntry(arDeleted.GetAt(j));
-						if (childEntry->IsChecked())
-						{
-							if (path.IsAncestorOf(childEntry->GetPath()))
-							{
-								m_ListCtrl.SetEntryCheck(childEntry, arDeleted.GetAt(j), false);
-								nDeleted--;
-							}
-						}
-					}
+					m_ListCtrl.SetEntryCheck(childEntry, arDeleted.GetAt(j), false);
+					nDeleted--;
 				}
 			}
 		}
@@ -601,7 +598,7 @@
 	}
 
 	// now let the bugtraq plugin check the commit message
-	CComPtr<IBugTraqProvider2> pProvider2 = NULL;
+	CComPtr<IBugTraqProvider2> pProvider2;
 	if (m_BugTraqProvider)
 	{
 		HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2);
@@ -638,8 +635,6 @@
 		}
 	}
 
-
-
 	m_History.AddEntry(m_sLogMessage);
 	m_History.Save();
 
@@ -1361,7 +1356,7 @@
 	m_revProps.clear();
 
 	// first try the IBugTraqProvider2 interface
-	CComPtr<IBugTraqProvider2> pProvider2 = NULL;
+	CComPtr<IBugTraqProvider2> pProvider2;
 	HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider2);
 	if (SUCCEEDED(hr))
 	{
@@ -1411,7 +1406,7 @@
 	else
 	{
 		// if IBugTraqProvider2 failed, try IBugTraqProvider
-		CComPtr<IBugTraqProvider> pProvider = NULL;
+		CComPtr<IBugTraqProvider> pProvider;
 		hr = m_BugTraqProvider.QueryInterface(&pProvider);
 		if (FAILED(hr))
 		{
Index: TortoiseProc/RevisionGraph/RevisionGraphDlgFunc.cpp
===================================================================
--- TortoiseProc/RevisionGraph/RevisionGraphDlgFunc.cpp	(revision 18366)
+++ TortoiseProc/RevisionGraph/RevisionGraphDlgFunc.cpp	(working copy)
@@ -158,17 +158,15 @@
 
 int CRevisionGraphWnd::GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
 {
-	UINT  num = 0;          // number of image encoders
-	UINT  size = 0;         // size of the image encoder array in bytes
+	UINT num = 0;          // number of image encoders
+	UINT size = 0;         // size of the image encoder array in bytes
 
-	ImageCodecInfo* pImageCodecInfo = NULL;
-
 	if (GetImageEncodersSize(&num, &size)!=Ok)
 		return -1;
 	if(size == 0)
 		return -1;  // Failure
 
-	pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
+	ImageCodecInfo* pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
 	if(pImageCodecInfo == NULL)
 		return -1;  // Failure
 
@@ -419,4 +417,3 @@
 
     Invalidate (FALSE);
 }
-
Index: TortoiseProc/Settings/SetOverlayIcons.cpp
===================================================================
--- TortoiseProc/Settings/SetOverlayIcons.cpp	(revision 18366)
+++ TortoiseProc/Settings/SetOverlayIcons.cpp	(working copy)
@@ -196,22 +196,10 @@
 	DestroyIcon(hUnversionedOverlay);
 
 	// create an image list with different file icons
-	SHFILEINFO sfi;
-	SecureZeroMemory(&sfi, sizeof sfi);
+	const hIcon = GetFileIcon(_T("Doesn't matter"), bSmallIcons, FILE_ATTRIBUTE_DIRECTORY);
+	int folderindex = pImageList->Add(hIcon);	//folder
+	DestroyIcon(hIcon);
 
-	UINT flags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES;
-	if (bSmallIcons)
-		flags |= SHGFI_SMALLICON;
-	else
-		flags |= SHGFI_LARGEICON;
-	SHGetFileInfo(
-		_T("Doesn't matter"),
-		FILE_ATTRIBUTE_DIRECTORY,
-		&sfi, sizeof sfi,
-		flags);
-
-	int folderindex = pImageList->Add(sfi.hIcon);	//folder
-	DestroyIcon(sfi.hIcon);
 	//folders
 	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sNormal, folderindex);
 	VERIFY(m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(1), TVIS_OVERLAYMASK));
@@ -263,27 +251,15 @@
 }
 void CSetOverlayIcons::AddFileTypeGroup(CString sFileType, bool bSmallIcons)
 {
-	UINT flags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES;
-	if (bSmallIcons)
-		flags |= SHGFI_SMALLICON;
-	else
-		flags |= SHGFI_LARGEICON;
-	SHFILEINFO sfi;
-	SecureZeroMemory(&sfi, sizeof sfi);
+	const HICON hIcon = GetFileIcon(sFileType, bSmallIcons, FILE_ATTRIBUTE_NORMAL);
 
-	SHGetFileInfo(
-		sFileType,
-		FILE_ATTRIBUTE_NORMAL,
-		&sfi, sizeof sfi,
-		flags);
-
 	int imageindex = 0;
 	if (bSmallIcons)
-		imageindex = m_ImageList.Add(sfi.hIcon);
+		imageindex = m_ImageList.Add(hIcon);
 	else
-		imageindex = m_ImageListBig.Add(sfi.hIcon);
+		imageindex = m_ImageListBig.Add(hIcon);
 
-	DestroyIcon(sfi.hIcon);
+	DestroyIcon(hIcon);
 	int index = 0;
 	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sNormal+sFileType, imageindex);
 	m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(1), TVIS_OVERLAYMASK);
@@ -353,3 +329,21 @@
 	SetModified(FALSE);
 	return ISettingsPropPage::OnApply();
 }
+
+HICON CSetOverlayIcons::GetFileIcon(LPCTSTR fileType, bool bSmallIcons, DWORD attributes)
+{
+	SHFILEINFO sfi;
+	SecureZeroMemory(&sfi, sizeof sfi);
+
+	UINT flags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES;
+	if (bSmallIcons)
+		flags |= SHGFI_SMALLICON;
+	else
+		flags |= SHGFI_LARGEICON;
+	SHGetFileInfo(
+		fileType,
+		attributes,
+		&sfi, sizeof sfi,
+		flags);
+	return sfi.hIcon;
+}
Index: TortoiseProc/Settings/SetOverlayIcons.h
===================================================================
--- TortoiseProc/Settings/SetOverlayIcons.h	(revision 18366)
+++ TortoiseProc/Settings/SetOverlayIcons.h	(working copy)
@@ -48,6 +48,7 @@
 
 	void					ShowIconSet(bool bSmallIcons);
 	void					AddFileTypeGroup(CString sFileType, bool bSmallIcons);
+	HICON					GetFileIcon(LPCTSTR fileType, bool smallIcons, DWORD attributes);
 	DECLARE_MESSAGE_MAP()
 protected:
 	int				m_selIndex;
Index: TortoiseProc/Settings/SetSavedDataPage.cpp
===================================================================
--- TortoiseProc/Settings/SetSavedDataPage.cpp	(revision 18366)
+++ TortoiseProc/Settings/SetSavedDataPage.cpp	(working copy)
@@ -239,14 +239,7 @@
 	{
 		_tcscat_s(pathbuf, MAX_PATH, _T("\\Subversion\\auth"));
 		pathbuf[_tcslen(pathbuf)+1] = 0;
-		SHFILEOPSTRUCT fileop;
-		fileop.hwnd = this->m_hWnd;
-		fileop.wFunc = FO_DELETE;
-		fileop.pFrom = pathbuf;
-		fileop.pTo = NULL;
-		fileop.fFlags = FOF_NO_CONNECTED_ELEMENTS | FOF_NOCONFIRMATION;// | FOF_NOERRORUI | FOF_SILENT;
-		fileop.lpszProgressTitle = _T("deleting file");
-		SHFileOperation(&fileop);
+		DeleteViaShell(pathbuf, _T("deleting file"));
 	}
 	DialogEnableWindow(&m_btnAuthHistClear, false);
 	m_tooltips.DelTool(GetDlgItem(IDC_AUTHHISTCLEAR));
@@ -260,14 +253,7 @@
 	_tcscpy_s(pathbuf, MAX_PATH, (LPCTSTR)path);
 	pathbuf[_tcslen(pathbuf)+1] = 0;
 
-	SHFILEOPSTRUCT fileop = {0};
-	fileop.hwnd = this->m_hWnd;
-	fileop.wFunc = FO_DELETE;
-	fileop.pFrom = pathbuf;
-	fileop.pTo = NULL;
-	fileop.fFlags = FOF_NO_CONNECTED_ELEMENTS | FOF_NOCONFIRMATION;
-	fileop.lpszProgressTitle = _T("deleting cached data");
-	SHFileOperation(&fileop);
+	DeleteViaShell(pathbuf, _T("deleting cached data"));
 
 	DialogEnableWindow(&m_btnRepoLogClear, false);
 	m_tooltips.DelTool(GetDlgItem(IDC_REPOLOG));
@@ -299,3 +285,14 @@
     return ISettingsPropPage::OnApply();
 }
 
+void CSetSavedDataPage::DeleteViaShell(LPCTSTR path, LPCTSTR progressText)
+{
+	SHFILEOPSTRUCT fileop;
+	fileop.hwnd = m_hWnd;
+	fileop.wFunc = FO_DELETE;
+	fileop.pFrom = path;
+	fileop.pTo = NULL;
+	fileop.fFlags = FOF_NO_CONNECTED_ELEMENTS | FOF_NOCONFIRMATION;
+	fileop.lpszProgressTitle = progressText;
+	SHFileOperation(&fileop);
+}
Index: TortoiseProc/Settings/SetSavedDataPage.h
===================================================================
--- TortoiseProc/Settings/SetSavedDataPage.h	(revision 18366)
+++ TortoiseProc/Settings/SetSavedDataPage.h	(working copy)
@@ -54,6 +54,7 @@
 	virtual BOOL OnInitDialog();
 	virtual BOOL PreTranslateMessage(MSG* pMsg);
 	virtual BOOL OnApply();
+	void DeleteViaShell(LPCTSTR path, LPCTSTR progressText);
 private:
 	CToolTips		m_tooltips;
 	CButton			m_btnUrlHistClear;
Index: TortoiseProc/SVNProgressDlg.cpp
===================================================================
--- TortoiseProc/SVNProgressDlg.cpp	(revision 18366)
+++ TortoiseProc/SVNProgressDlg.cpp	(working copy)
@@ -2178,7 +2178,7 @@
 	{
 		if (m_BugTraqProvider)
 		{
-			CComPtr<IBugTraqProvider2> pProvider = NULL;
+			CComPtr<IBugTraqProvider2> pProvider;
 			HRESULT hr = m_BugTraqProvider.QueryInterface(&pProvider);
 			if (SUCCEEDED(hr))
 			{
Index: TortoiseProc/TortoiseProc.cpp
===================================================================
--- TortoiseProc/TortoiseProc.cpp	(revision 18366)
+++ TortoiseProc/TortoiseProc.cpp	(working copy)
@@ -446,8 +446,6 @@
 	return FALSE;
 }
 
-
-
 void CTortoiseProcApp::CheckUpgrade()
 {
 	CRegString regVersion = CRegString(_T("Software\\TortoiseSVN\\CurrentVersion"));
@@ -548,61 +546,59 @@
 {
 	// for Win7 : use a custom jump list
 	CoInitialize(NULL);
-
 	SetAppID(APPID);
 	DeleteJumpList(APPID);
-	ICustomDestinationList *pcdl;
-	HRESULT hr = CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pcdl));
+	DoInitializeJumpList();	
+	CoUninitialize();
+}
+
+void CTortoiseProcApp::DoInitializeJumpList()
+{
+	ATL::CComPtr<ICustomDestinationList> pcdl;
+	HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER);
+	if (FAILED(hr))
+		return;
+
+	hr = pcdl->SetAppID(APPID);
+	if (FAILED(hr))
+		return;
+
+	UINT uMaxSlots;
+	ATL::CComPtr<IObjectArray> poaRemoved;
+	hr = pcdl->BeginList(&uMaxSlots, IID_PPV_ARGS(&poaRemoved));
+	if (FAILED(hr))
+		return;
+
+	ATL::CComPtr<IObjectCollection> poc;
+	hr = poc.CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER);
+	if (FAILED(hr))
+		return;
+
+	CString sTemp = CString(MAKEINTRESOURCE(IDS_MENUSETTINGS));
+	CStringUtils::RemoveAccelerators(sTemp);
+
+	ATL::CComPtr<IShellLink> psl;
+	hr = CreateShellLink(_T("/command:settings"), (LPCTSTR)sTemp, 19, &psl);
 	if (SUCCEEDED(hr))
 	{
-		hr = pcdl->SetAppID(APPID);
-		if (SUCCEEDED(hr))
-		{
-			UINT uMaxSlots;
-			IObjectArray *poaRemoved;
-			hr = pcdl->BeginList(&uMaxSlots, IID_PPV_ARGS(&poaRemoved));
-			if (SUCCEEDED(hr))
-			{
-				IObjectCollection *poc;
-				hr = CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&poc));
-				if (SUCCEEDED(hr))
-				{
-					IShellLink *psl;
-					CString sTemp = CString(MAKEINTRESOURCE(IDS_MENUSETTINGS));
-					CStringUtils::RemoveAccelerators(sTemp);
-					hr = CreateShellLink(_T("/command:settings"), (LPCTSTR)sTemp, 19, &psl);
-					if (SUCCEEDED(hr))
-					{
-						poc->AddObject(psl);
-						psl->Release();
-					}
-					sTemp = CString(MAKEINTRESOURCE(IDS_MENUHELP));
-					CStringUtils::RemoveAccelerators(sTemp);
-					hr = CreateShellLink(_T("/command:help"), (LPCTSTR)sTemp, 18, &psl);
-					if (SUCCEEDED(hr))
-					{
-						poc->AddObject(psl);
-						psl->Release();
-					}
+		poc->AddObject(psl);
+	}
+	sTemp = CString(MAKEINTRESOURCE(IDS_MENUHELP));
+	CStringUtils::RemoveAccelerators(sTemp);
+	psl.Release(); // Need to release the object before calling operator&()
+	hr = CreateShellLink(_T("/command:help"), (LPCTSTR)sTemp, 18, &psl);
+	if (SUCCEEDED(hr))
+	{
+		poc->AddObject(psl);
+	}
 
-					IObjectArray *poa;
-					hr = poc->QueryInterface(IID_PPV_ARGS(&poa));
-					if (SUCCEEDED(hr))
-					{
-						pcdl->AppendCategory((LPCTSTR)CString(MAKEINTRESOURCE(IDS_PROC_TASKS)), poa);
-						poa->Release();
-					}
-					poc->Release();
-				}				
-				if (SUCCEEDED(hr))
-				{
-					pcdl->CommitList();
-				}
-				poaRemoved->Release();
-			}
-		}
+	ATL::CComPtr<IObjectArray> poa;
+	hr = poc.QueryInterface(&poa);
+	if (SUCCEEDED(hr))
+	{
+		pcdl->AppendCategory((LPCTSTR)CString(MAKEINTRESOURCE(IDS_PROC_TASKS)), poa);
+		pcdl->CommitList();
 	}
-	CoUninitialize();
 }
 
 int CTortoiseProcApp::ExitInstance()
Index: TortoiseProc/TortoiseProc.h
===================================================================
--- TortoiseProc/TortoiseProc.h	(revision 18366)
+++ TortoiseProc/TortoiseProc.h	(working copy)
@@ -62,9 +62,8 @@
 // Implementation
 
 private:
-
-
 	DECLARE_MESSAGE_MAP()
+	void DoInitializeJumpList();
 private:
 	bool	retSuccess;
 };
Index: TortoiseShell/ContextMenu.cpp
===================================================================
--- TortoiseShell/ContextMenu.cpp	(revision 18366)
+++ TortoiseShell/ContextMenu.cpp	(working copy)
@@ -2185,12 +2185,10 @@
 void CShellExt::RunCommand(const tstring& path, const tstring& command,
 	const tstring& folder, LPCTSTR errorMessage)
 {
-	PROCESS_INFORMATION process;
-	if (CCreateProcessHelper::CreateProcess(path.c_str(), const_cast<TCHAR*>(command.c_str()), folder.c_str(), &process))
+	if (CCreateProcessHelper::CreateProcessDetached(path.c_str(),
+		const_cast<TCHAR*>(command.c_str()), folder.c_str()))
 	{
-		// process started - close handles and exit
-		CloseHandle(process.hThread);
-		CloseHandle(process.hProcess);
+		// process started - exit
 		return;
 	}
 
Index: TortoiseShell/RemoteCacheLink.cpp
===================================================================
--- TortoiseShell/RemoteCacheLink.cpp	(revision 18366)
+++ TortoiseShell/RemoteCacheLink.cpp	(working copy)
@@ -183,17 +183,14 @@
 		if (GetProcessIntegrityLevel() < SECURITY_MANDATORY_MEDIUM_RID)
 			return false;
 
-		PROCESS_INFORMATION process;
 		CString sCachePath = CPathUtils::GetAppDirectory(g_hmodThisDll) + _T("TSVNCache.exe");
-		if (!CCreateProcessHelper::CreateProcess(sCachePath.GetBuffer(sCachePath.GetLength()+1), NULL, &process))
+		if (!CCreateProcessHelper::CreateProcessDetached( sCachePath.GetBuffer(sCachePath.GetLength()+1), NULL))
 		{
 			// It's not appropriate to do a message box here, because there may be hundreds of calls
 			sCachePath.ReleaseBuffer();
 			ATLTRACE("Failed to start cache\n");
 			return false;
 		}
-		CloseHandle(process.hThread);
-		CloseHandle(process.hProcess);
 		sCachePath.ReleaseBuffer();
 
 		// Wait for the cache to open
Index: TortoiseShell/ShellExtClassFactory.cpp
===================================================================
--- TortoiseShell/ShellExtClassFactory.cpp	(revision 18366)
+++ TortoiseShell/ShellExtClassFactory.cpp	(working copy)
@@ -90,15 +90,11 @@
     // QueryInterface with IID_IShellExtInit--this is how shell extensions are
     // initialized.
 	
-    CShellExt* pShellExt = new (std::nothrow) CShellExt(m_StateToMake);  //Create the CShellExt object
+	ATL::CComPtr<CShellExt> pShellExt = new (std::nothrow) CShellExt(m_StateToMake);  //Create the CShellExt object
 		
     if (NULL == pShellExt)
         return E_OUTOFMEMORY;
-	
-    const HRESULT hr = pShellExt->QueryInterface(riid, ppvObj);
-	if(FAILED(hr))
-		delete pShellExt;
-	return hr;
+	return pShellExt->QueryInterface(riid, ppvObj);
 }
 
 STDMETHODIMP CShellExtClassFactory::LockServer(BOOL /*fLock*/)
Index: TortoiseShell/SVNPropertyPage.cpp
===================================================================
--- TortoiseShell/SVNPropertyPage.cpp	(revision 18366)
+++ TortoiseShell/SVNPropertyPage.cpp	(working copy)
@@ -425,11 +425,6 @@
 
 void CSVNPropertyPage::RunCommand(const tstring& command)
 {
-	PROCESS_INFORMATION process;
 	tstring tortoiseProcPath = GetAppDirectory() + _T("TortoiseProc.exe");
-	if (!CCreateProcessHelper::CreateProcess(tortoiseProcPath.c_str(), const_cast<TCHAR*>(command.c_str()), &process))
-		return;
-
-	CloseHandle(process.hThread);
-	CloseHandle(process.hProcess);
+	CCreateProcessHelper::CreateProcessDetached(tortoiseProcPath.c_str(), const_cast<TCHAR*>(command.c_str()));
 }
Index: TortoiseShell/TortoiseSVN.cpp
===================================================================
--- TortoiseShell/TortoiseSVN.cpp	(revision 18366)
+++ TortoiseShell/TortoiseSVN.cpp	(working copy)
@@ -128,7 +128,9 @@
 
 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppvOut)
 {
-    *ppvOut = NULL;
+	if (ppvOut == 0 )
+		return E_POINTER;
+	*ppvOut = NULL;
 	
     FileState state = FileStateInvalid;
     if (IsEqualIID(rclsid, CLSID_TortoiseSVN_UPTODATE))
@@ -161,18 +163,11 @@
 		g_SVNAdminDir.Init();
 		g_cAprInit++;
 		
-		CShellExtClassFactory *pcf = new (std::nothrow) CShellExtClassFactory(state);
+		ATL::CComPtr<CShellExtClassFactory> pcf = new (std::nothrow) CShellExtClassFactory(state);
 		if (pcf == NULL)
 			return E_OUTOFMEMORY;
-		// refcount currently set to 0
-		const HRESULT hr = pcf->QueryInterface(riid, ppvOut);
-		if(FAILED(hr))
-			delete pcf;
-		return hr;
+		return pcf->QueryInterface(riid, ppvOut);
     }
 	
     return CLASS_E_CLASSNOTAVAILABLE;
-
 }
-
-
Index: Utils/CreateProcessHelper.h
===================================================================
--- Utils/CreateProcessHelper.h	(revision 18366)
+++ Utils/CreateProcessHelper.h	(working copy)
@@ -33,6 +33,12 @@
 	static bool CreateProcess(LPCTSTR lpApplicationName,
 					LPTSTR lpCommandLine,
 					LPPROCESS_INFORMATION lpProcessInformation);
+
+	static bool CreateProcessDetached(LPCTSTR lpApplicationName,
+					LPTSTR lpCommandLine,
+					LPCTSTR lpCurrentDirectory);
+	static bool CreateProcessDetached(LPCTSTR lpApplicationName,
+					LPTSTR lpCommandLine);
 };
 
 inline bool CCreateProcessHelper::CreateProcess(LPCTSTR applicationName,
@@ -55,3 +61,21 @@
 {
 	return CreateProcess( applicationName, commandLine, 0, processInformation );
 }
+
+inline bool CCreateProcessHelper::CreateProcessDetached(LPCTSTR lpApplicationName,
+	LPTSTR lpCommandLine, LPCTSTR lpCurrentDirectory)
+{
+	PROCESS_INFORMATION process;
+	if (!CreateProcess(lpApplicationName, lpCommandLine, lpCurrentDirectory, &process))
+		return false;
+
+	CloseHandle(process.hThread);
+	CloseHandle(process.hProcess);
+	return true;
+}
+
+inline bool CCreateProcessHelper::CreateProcessDetached(LPCTSTR lpApplicationName,
+	LPTSTR lpCommandLine)
+{
+	return CreateProcessDetached(lpApplicationName, lpCommandLine, 0);
+}
Index: Utils/JumpListHelpers.cpp
===================================================================
--- Utils/JumpListHelpers.cpp	(revision 18366)
+++ Utils/JumpListHelpers.cpp	(working copy)
@@ -40,109 +40,102 @@
 
 HRESULT CreateShellLink(PCWSTR pszArguments, PCWSTR pszTitle, int iconIndex, IShellLink **ppsl)
 {
-    IShellLink *psl;
-    HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&psl));
-    if (SUCCEEDED(hr))
-    {
-        WCHAR szAppPath[MAX_PATH];
-        if (GetModuleFileName(NULL, szAppPath, ARRAYSIZE(szAppPath)))
-        {
-            hr = psl->SetPath(szAppPath);
-            if (SUCCEEDED(hr))
-            {
-                hr = psl->SetArguments(pszArguments);
-                if (SUCCEEDED(hr))
-                {
-					hr = psl->SetIconLocation(szAppPath, iconIndex);
-					if (SUCCEEDED(hr))
-					{
-						IPropertyStore *pps;
-						hr = psl->QueryInterface(IID_PPV_ARGS(&pps));
-						if (SUCCEEDED(hr))
-						{
-							PROPVARIANT propvar;
-							hr = InitPropVariantFromString(pszTitle, &propvar);
-							if (SUCCEEDED(hr))
-							{
-								hr = pps->SetValue(PKEY_Title, propvar);
-								if (SUCCEEDED(hr))
-								{
-									hr = pps->Commit();
-									if (SUCCEEDED(hr))
-									{
-										hr = psl->QueryInterface(IID_PPV_ARGS(ppsl));
-									}
-								}
-								PropVariantClear(&propvar);
-							}
-							pps->Release();
-						}
-					}
-                }
-            }
-        }
-		else
+	ATL::CComPtr<IShellLink> psl;
+	HRESULT hr = psl.CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER);
+    if (FAILED(hr))
+		return hr;
+
+	WCHAR szAppPath[MAX_PATH];
+	if (GetModuleFileName(NULL, szAppPath, ARRAYSIZE(szAppPath)) == 0)
+	{
+		hr = HRESULT_FROM_WIN32(GetLastError());
+		return hr;
+	}
+	hr = psl->SetPath(szAppPath);
+	if (FAILED(hr))
+		return hr;
+
+	hr = psl->SetArguments(pszArguments);
+	if (FAILED(hr))
+		return hr;
+
+	hr = psl->SetIconLocation(szAppPath, iconIndex);
+	if (FAILED(hr))
+		return hr;
+
+	ATL::CComPtr<IPropertyStore> pps;
+	hr = psl.QueryInterface(&pps);
+	if (FAILED(hr))
+		return hr;
+
+	PROPVARIANT propvar;
+	hr = InitPropVariantFromString(pszTitle, &propvar);
+	if (SUCCEEDED(hr))
+	{
+		hr = pps->SetValue(PKEY_Title, propvar);
+		if (SUCCEEDED(hr))
 		{
-			hr = HRESULT_FROM_WIN32(GetLastError());
+			hr = pps->Commit();
+			if (SUCCEEDED(hr))
+			{
+				hr = psl.QueryInterface(ppsl);
+			}
 		}
-        psl->Release();
-    }    
+		PropVariantClear(&propvar);
+	}
     return hr;
 }
 
 HRESULT CreateSeparatorLink(IShellLink **ppsl)
 {
-    IPropertyStore *pps;
-    HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pps));
-    if (SUCCEEDED(hr))
-    {
-        PROPVARIANT propvar;
-        hr = InitPropVariantFromBoolean(TRUE, &propvar);
-        if (SUCCEEDED(hr))
-        {
-			hr = pps->SetValue(PKEY_AppUserModel_IsDestListSeparator, propvar);
-            if (SUCCEEDED(hr))
-            {
-                hr = pps->Commit();
-                if (SUCCEEDED(hr))
-                {
-                    hr = pps->QueryInterface(IID_PPV_ARGS(ppsl));
-                }
-            }
-            PropVariantClear(&propvar);
-        }
-        pps->Release();
+	ATL::CComPtr<IPropertyStore> pps;
+    HRESULT hr = pps.CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER);
+    if (FAILED(hr))
+		return hr;
+
+	PROPVARIANT propvar;
+	hr = InitPropVariantFromBoolean(TRUE, &propvar);
+	if (FAILED(hr))
+		return hr;
+
+	hr = pps->SetValue(PKEY_AppUserModel_IsDestListSeparator, propvar);
+	if (SUCCEEDED(hr))
+	{
+		hr = pps->Commit();
+		if (SUCCEEDED(hr))
+		{
+			hr = pps.QueryInterface(ppsl);
+		}
 	}
+	PropVariantClear(&propvar);
 	return hr;
 }
 
 bool IsItemInArray(IShellItem *psi, IObjectArray *poaRemoved)
 {
-	bool fRet = false;
+	
 	UINT cItems;
-	if (SUCCEEDED(poaRemoved->GetCount(&cItems)))
+	if (FAILED(poaRemoved->GetCount(&cItems)))
+		return false;
+
+	bool fRet = false;
+	for (UINT i = 0; !fRet && i < cItems; i++)
 	{
-		IShellItem *psiCompare;
-		for (UINT i = 0; !fRet && i < cItems; i++)
-		{
-			if (SUCCEEDED(poaRemoved->GetAt(i, IID_PPV_ARGS(&psiCompare))))
-			{
-				int iOrder;
-				fRet = SUCCEEDED(psiCompare->Compare(psi, SICHINT_CANONICAL, &iOrder)) && (0 == iOrder);
-				psiCompare->Release();
-			}
-		}
+		ATL::CComPtr<IShellItem> psiCompare;
+		if (FAILED(poaRemoved->GetAt(i, IID_PPV_ARGS(&psiCompare))))
+			continue;
+		int iOrder;
+		fRet = SUCCEEDED(psiCompare->Compare(psi, SICHINT_CANONICAL, &iOrder)) && (0 == iOrder);
 	}
 	return fRet;
 }
 
 void DeleteJumpList(LPCTSTR appID)
 {
-	ICustomDestinationList *pcdl;
-	HRESULT hr = CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pcdl));
+	ATL::CComPtr<ICustomDestinationList> pcdl;
+	HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER);
 	if (SUCCEEDED(hr))
 	{
 		hr = pcdl->DeleteList(appID);
-		pcdl->Release();
 	}
-}
\ No newline at end of file
+}
Index: Utils/ListViewAccServer.cpp
===================================================================
--- Utils/ListViewAccServer.cpp	(revision 18366)
+++ Utils/ListViewAccServer.cpp	(working copy)
@@ -90,11 +90,11 @@
 
 ListViewAccServer * ListViewAccServer::CreateProvider(HWND hControl, ListViewAccProvider * provider)
 {
-	IAccPropServices * pAccPropSvc = NULL;
-	HRESULT hr = CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER, IID_IAccPropServices, (void **)&pAccPropSvc);
+	ATL::CComPtr<IAccPropServices> pAccPropSvc;
+	HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
 	if (hr == S_OK && pAccPropSvc)
 	{
-		ListViewAccServer * pLVServer = new ListViewAccServer(pAccPropSvc);
+		ListViewAccServer * pLVServer = new (std::nothrow) ListViewAccServer(pAccPropSvc);
 		if (pLVServer)
 		{
 			pLVServer->m_pAccProvider = provider;
@@ -103,8 +103,6 @@
 			pAccPropSvc->SetHwndPropServer(hControl, (DWORD)OBJID_CLIENT, CHILDID_SELF, &propid, 1, pLVServer, ANNO_CONTAINER);
 			pLVServer->Release();
 		}
-		pAccPropSvc->Release();
-
 		return pLVServer;
 	}
 	return NULL;
Index: Utils/MiscUI/ExtTextOutFL.h
===================================================================
--- Utils/MiscUI/ExtTextOutFL.h	(revision 18366)
+++ Utils/MiscUI/ExtTextOutFL.h	(working copy)
@@ -26,68 +26,67 @@
 
 HRESULT TextOutFL(HDC hdc, int x, int y, LPCWSTR psz, int cch)
 {
-	HRESULT hr;
-	IMLangFontLink2 *pfl;
-	if (SUCCEEDED(hr = CoCreateInstance(CLSID_CMultiLanguage, NULL,
-		CLSCTX_ALL, IID_IMLangFontLink2, (void**)&pfl))) 
+	ATL::CComPtr<IMLangFontLink2> pfl;
+	HRESULT hr = pfl.CoCreateInstance(CLSID_CMultiLanguage, NULL, CLSCTX_ALL);
+	if (FAILED(hr))
+		return hr;
+
+	HFONT hfOrig = (HFONT)GetCurrentObject(hdc, OBJ_FONT);
+	POINT ptOrig;
+	DWORD dwAlignOrig = GetTextAlign(hdc);
+	if (!(dwAlignOrig & TA_UPDATECP)) 
 	{
-			HFONT hfOrig = (HFONT)GetCurrentObject(hdc, OBJ_FONT);
-			POINT ptOrig;
-			DWORD dwAlignOrig = GetTextAlign(hdc);
-			if (!(dwAlignOrig & TA_UPDATECP)) 
+		SetTextAlign(hdc, dwAlignOrig | TA_UPDATECP);
+	}
+	MoveToEx(hdc, x, y, &ptOrig);
+	DWORD dwFontCodePages = 0;
+	hr = pfl->GetFontCodePages(hdc, hfOrig, &dwFontCodePages);
+	if (SUCCEEDED(hr)) 
+	{
+		while (cch > 0) 
+		{
+			DWORD dwActualCodePages;
+			long cchActual;
+			hr = pfl->GetStrCodePages(psz, cch, dwFontCodePages, &dwActualCodePages, &cchActual);
+			if (FAILED(hr)) 
 			{
-				SetTextAlign(hdc, dwAlignOrig | TA_UPDATECP);
+				break;
 			}
-			MoveToEx(hdc, x, y, &ptOrig);
-			DWORD dwFontCodePages = 0;
-			hr = pfl->GetFontCodePages(hdc, hfOrig, &dwFontCodePages);
-			if (SUCCEEDED(hr)) 
+
+			if (dwActualCodePages & dwFontCodePages) 
 			{
-				while (cch > 0) 
+				TextOut(hdc, 0, 0, psz, cchActual);
+			} 
+			else 
+			{
+				HFONT hfLinked;
+				if (FAILED(hr = pfl->MapFont(hdc, dwActualCodePages, 0, &hfLinked))) 
 				{
-					DWORD dwActualCodePages;
-					long cchActual;
-					hr = pfl->GetStrCodePages(psz, cch, dwFontCodePages, &dwActualCodePages, &cchActual);
-					if (FAILED(hr)) 
-					{
-						break;
-					}
-
-					if (dwActualCodePages & dwFontCodePages) 
-					{
-						TextOut(hdc, 0, 0, psz, cchActual);
-					} 
-					else 
-					{
-						HFONT hfLinked;
-						if (FAILED(hr = pfl->MapFont(hdc, dwActualCodePages, 0, &hfLinked))) 
-						{
-							break;
-						}
-						SelectObject(hdc, (HGDIOBJ)(HFONT)hfLinked);
-						TextOut(hdc, 0, 0, psz, cchActual);
-						SelectObject(hdc, (HGDIOBJ)(HFONT)hfOrig);
-						pfl->ReleaseFont(hfLinked);
-					}
-					psz += cchActual;
-					cch -= cchActual;
+					break;
 				}
-				if (FAILED(hr)) 
-				{
-					//  We started outputting characters so we have to finish.
-					//  Do the rest without font linking since we have no choice.
-					TextOut(hdc, 0, 0, psz, cch);
-					hr = S_FALSE;
-				}
+				SelectObject(hdc, (HGDIOBJ)(HFONT)hfLinked);
+				TextOut(hdc, 0, 0, psz, cchActual);
+				SelectObject(hdc, (HGDIOBJ)(HFONT)hfOrig);
+				pfl->ReleaseFont(hfLinked);
 			}
+			psz += cchActual;
+			cch -= cchActual;
+		}
+		if (FAILED(hr)) 
+		{
+			//  We started outputting characters so we have to finish.
+			//  Do the rest without font linking since we have no choice.
+			TextOut(hdc, 0, 0, psz, cch);
+			hr = S_FALSE;
+		}
+	}
 
-			pfl->Release();
+	pfl.Release();
 
-			if (!(dwAlignOrig & TA_UPDATECP)) 
-			{
-				SetTextAlign(hdc, dwAlignOrig);
-				MoveToEx(hdc, ptOrig.x, ptOrig.y, NULL);
-			}
+	if (!(dwAlignOrig & TA_UPDATECP)) 
+	{
+		SetTextAlign(hdc, dwAlignOrig);
+		MoveToEx(hdc, ptOrig.x, ptOrig.y, NULL);
 	}
 
 	return hr;
Index: Utils/MiscUI/ProgressDlg.cpp
===================================================================
--- Utils/MiscUI/ProgressDlg.cpp	(revision 18366)
+++ Utils/MiscUI/ProgressDlg.cpp	(working copy)
@@ -21,7 +21,6 @@
 
 CProgressDlg::CProgressDlg() 
 	: m_pIDlg(NULL)
-	, m_bValid(false)		//not valid by default
 	, m_isVisible(false)
 	, m_dwDlgFlags(PROGDLG_NORMAL)
 	, m_hWndProgDlg(NULL)
@@ -31,34 +30,29 @@
 
 CProgressDlg::~CProgressDlg()
 {
-    if (m_bValid)
+    if (IsValid())
     {
 	    if (m_isVisible)			//still visible, so stop first before destroying
 	        m_pIDlg->StopProgressDialog();
 
-    	m_pIDlg->Release();
+		m_pIDlg.Release();
 		m_hWndProgDlg = NULL;
     }
 }
 
 bool CProgressDlg::EnsureValid()
 {
-	if(m_bValid)
+	if(IsValid())
 		return true;
 
-	HRESULT hr = CoCreateInstance (CLSID_ProgressDialog, NULL, CLSCTX_INPROC_SERVER,
-		IID_IProgressDialog, (void**)&m_pIDlg);
-
-	if (SUCCEEDED(hr))
-		m_bValid = true;				//instance successfully created
-
-	return m_bValid;
+	HRESULT hr = m_pIDlg.CoCreateInstance (CLSID_ProgressDialog, NULL, CLSCTX_INPROC_SERVER);
+	return (SUCCEEDED(hr));
 }
 
 void CProgressDlg::SetTitle(LPCTSTR szTitle)
 {
     USES_CONVERSION;
-    if (m_bValid)
+    if (IsValid())
 	{
 		m_pIDlg->SetTitle(T2COLE(szTitle));
 	}
@@ -71,7 +65,7 @@
 void CProgressDlg::SetLine(DWORD dwLine, LPCTSTR szText, bool bCompactPath /* = false */)
 {
 	USES_CONVERSION;
-	if (m_bValid)
+	if (IsValid())
 	{
 		m_pIDlg->SetLine(dwLine, T2COLE(szText), bCompactPath, NULL);
 	}
@@ -87,7 +81,7 @@
 void CProgressDlg::SetCancelMsg(LPCTSTR szMessage)
 {
     USES_CONVERSION;
-	if (m_bValid)
+	if (IsValid())
 	{
 		m_pIDlg->SetCancelMsg(T2COLE(szMessage), NULL);
 	}
@@ -95,7 +89,7 @@
 
 void CProgressDlg::SetAnimation(HINSTANCE hinst, UINT uRsrcID)
 {
-	if (m_bValid)
+	if (IsValid())
 	{
 		m_pIDlg->SetAnimation(hinst, uRsrcID);
 	}
@@ -103,7 +97,7 @@
 #ifdef _MFC_VER
 void CProgressDlg::SetAnimation(UINT uRsrcID)
 {
-	if (m_bValid)
+	if (IsValid())
 	{
 		m_pIDlg->SetAnimation(AfxGetResourceHandle(), uRsrcID);
 	}
@@ -182,7 +176,7 @@
 //{
 //	EnsureValid();
 //	HRESULT hr;
-//	if (m_bValid)
+//	if (IsValid())
 //	{
 //
 //		hr = m_pIDlg->StartProgressDialog(hWndParent,
@@ -203,7 +197,7 @@
 {
 	EnsureValid();
 	m_hWndProgDlg = NULL;
-	if (!m_bValid)
+	if (!IsValid())
 		return E_FAIL;
 
 	HRESULT hr = m_pIDlg->StartProgressDialog(hWndParent, NULL, m_dwDlgFlags, NULL);
@@ -218,8 +212,8 @@
 	// The progress window can be remarkably slow to display, particularly
 	// if its parent is blocked.
 	// This process finds the hwnd for the progress window and gives it a kick...
-	IOleWindow *pOleWindow;
-	HRESULT hr2 = m_pIDlg->QueryInterface(IID_IOleWindow,(LPVOID *)&pOleWindow);
+	ATL::CComPtr<IOleWindow> pOleWindow;
+	HRESULT hr2 = m_pIDlg.QueryInterface(&pOleWindow);
 	if(SUCCEEDED(hr2))
 	{
 		hr2 = pOleWindow->GetWindow(&m_hWndProgDlg);
@@ -227,14 +221,13 @@
 		{
 			ShowWindow(m_hWndProgDlg, SW_NORMAL);
 		}
-		pOleWindow->Release();
 	}
 	return hr;
 }
 
 void CProgressDlg::SetProgress(DWORD dwProgress, DWORD dwMax)
 {
-	if (m_bValid)
+	if (IsValid())
 	{
 		m_pIDlg->SetProgress(dwProgress, dwMax);
 	}
@@ -242,7 +235,7 @@
 
 void CProgressDlg::SetProgress64(ULONGLONG u64Progress, ULONGLONG u64ProgressMax)
 {
-	if (m_bValid)
+	if (IsValid())
 	{
 		m_pIDlg->SetProgress64(u64Progress, u64ProgressMax);
 	}
@@ -250,7 +243,7 @@
 
 bool CProgressDlg::HasUserCancelled()
 {
-	if (!m_bValid)
+	if (!IsValid())
 		return false;
 
 	return (0 != m_pIDlg->HasUserCancelled());
@@ -258,7 +251,7 @@
 
 void CProgressDlg::Stop()
 {
-    if ((m_isVisible)&&(m_bValid))
+    if ((m_isVisible)&&(IsValid()))
     {
         m_pIDlg->StopProgressDialog();
 		// Sometimes the progress dialog sticks around after stopping it,
@@ -269,15 +262,14 @@
 			ShowWindow(m_hWndProgDlg, SW_HIDE);
 		}
         m_isVisible = false;
-		m_pIDlg->Release();
-		m_bValid = false;
+		m_pIDlg.Release();
 		m_hWndProgDlg = NULL;
     }
 }
 
 void CProgressDlg::ResetTimer()
 {
-	if (m_bValid)
+	if (IsValid())
 	{
 		m_pIDlg->Timer(PDTIMER_RESET, NULL);
 	}
Index: Utils/MiscUI/ProgressDlg.h
===================================================================
--- Utils/MiscUI/ProgressDlg.h	(revision 18366)
+++ Utils/MiscUI/ProgressDlg.h	(working copy)
@@ -159,7 +159,7 @@
 	 * Checks whether this object was created successfully. If the return value is false then 
 	 * you MUST NOT use the current instance of this class.
 	 */
-    bool IsValid() const { return m_bValid; }
+    bool IsValid() const { return m_pIDlg != 0; }
 
 	/**
 	 * Checks whether the window is shown.
@@ -174,10 +174,8 @@
 	bool EnsureValid();
 
 protected:
-    IProgressDialog*	m_pIDlg;
-    bool				m_bValid;
+	ATL::CComPtr<IProgressDialog> m_pIDlg;
     bool				m_isVisible;
     DWORD				m_dwDlgFlags;
 	HWND				m_hWndProgDlg;
 };
-
Index: Utils/SysImageList.cpp
===================================================================
--- Utils/SysImageList.cpp	(revision 18366)
+++ Utils/SysImageList.cpp	(working copy)
@@ -20,7 +20,6 @@
 #include "SysImageList.h"
 #include "TSVNPath.h"
 
-
 // Singleton constructor and destructor (private)
 
 CSysImageList * CSysImageList::instance = 0;
@@ -44,7 +43,6 @@
 	Detach();
 }
 
-
 // Singleton specific operations
 
 CSysImageList& CSysImageList::GetInstance()
@@ -60,7 +58,6 @@
 	instance = 0;
 }
 
-
 // Operations
 
 int CSysImageList::AddIcon(const HICON hIcon)
@@ -70,58 +67,22 @@
 
 int CSysImageList::GetDirIconIndex() const
 {
-	SHFILEINFO sfi;
-	SecureZeroMemory(&sfi, sizeof sfi);
-
-	SHGetFileInfo(
-		_T("Doesn't matter"),
-		FILE_ATTRIBUTE_DIRECTORY,
-		&sfi, sizeof sfi,
-		SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
-
-	return sfi.iIcon;
+	return GetFileIcon(_T("Doesn't matter"), FILE_ATTRIBUTE_DIRECTORY, 0);
 }
 
 int CSysImageList::GetDirOpenIconIndex() const
 {
-	SHFILEINFO sfi;
-	SecureZeroMemory(&sfi, sizeof sfi);
-
-	SHGetFileInfo(
-		_T("Doesn't matter"),
-		FILE_ATTRIBUTE_DIRECTORY,
-		&sfi, sizeof sfi,
-		SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES | SHGFI_OPENICON);
-
-	return sfi.iIcon;
+	return GetFileIcon(_T("Doesn't matter"), FILE_ATTRIBUTE_DIRECTORY, SHGFI_OPENICON);
 }
 
 int CSysImageList::GetDefaultIconIndex() const
 {
-	SHFILEINFO sfi;
-	SecureZeroMemory(&sfi, sizeof sfi);
-
-	SHGetFileInfo(
-		_T(""),
-		FILE_ATTRIBUTE_NORMAL,
-		&sfi, sizeof sfi,
-		SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
-
-	return sfi.iIcon;
+	return GetFileIcon(_T(""), FILE_ATTRIBUTE_NORMAL, 0);
 }
 
 int CSysImageList::GetFileIconIndex(const CString& file) const
 {
-	SHFILEINFO sfi;
-	SecureZeroMemory(&sfi, sizeof sfi);
-
-	SHGetFileInfo(
-		file,
-		FILE_ATTRIBUTE_NORMAL,
-		&sfi, sizeof sfi,
-		SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES);
-
-	return sfi.iIcon;
+	return GetFileIcon(file, FILE_ATTRIBUTE_NORMAL, 0);
 }
 
 int CSysImageList::GetPathIconIndex(const CTSVNPath& filePath) const
@@ -138,3 +99,17 @@
 	// We must have found it
 	return it->second;
 }
+
+int CSysImageList::GetFileIcon( LPCTSTR file, DWORD attributes, UINT extraFlags )
+{
+	SHFILEINFO sfi;
+	SecureZeroMemory(&sfi, sizeof sfi);
+
+	SHGetFileInfo(
+		file,
+		attributes,
+		&sfi, sizeof sfi,
+		SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES | extraFlags);
+
+	return sfi.iIcon;
+}
Index: Utils/SysImageList.h
===================================================================
--- Utils/SysImageList.h	(revision 18366)
+++ Utils/SysImageList.h	(working copy)
@@ -85,6 +85,8 @@
 
 	typedef std::map<CString, int> IconIndexMap;
 	mutable IconIndexMap m_indexCache;
+
+	int GetFileIcon( LPCTSTR file, DWORD attributes, UINT extraFlags );
 };
 
 
