diff --git a/com/win32com/src/ErrorUtils.cpp b/com/win32com/src/ErrorUtils.cpp
index c774e9f..a1d561a 100644
--- a/com/win32com/src/ErrorUtils.cpp
+++ b/com/win32com/src/ErrorUtils.cpp
@@ -1070,18 +1070,18 @@ LPCTSTR GetScodeRangeString(HRESULT hr)
     }
 
     static const RANGE_ENTRY hrRangeTable[] = {
-        MAKE_RANGE_ENTRY(CACHE_E),        MAKE_RANGE_ENTRY(CACHE_S),      MAKE_RANGE_ENTRY(CLASSFACTORY_E),
-        MAKE_RANGE_ENTRY(CLASSFACTORY_S), MAKE_RANGE_ENTRY(CLIENTSITE_E), MAKE_RANGE_ENTRY(CLIENTSITE_S),
-        MAKE_RANGE_ENTRY(CLIPBRD_E),      MAKE_RANGE_ENTRY(CLIPBRD_S),    MAKE_RANGE_ENTRY(CONVERT10_E),
-        MAKE_RANGE_ENTRY(CONVERT10_S),    MAKE_RANGE_ENTRY(CO_E),         MAKE_RANGE_ENTRY(CO_S),
-        MAKE_RANGE_ENTRY(DATA_E),         MAKE_RANGE_ENTRY(DATA_S),       MAKE_RANGE_ENTRY(DRAGDROP_E),
-        MAKE_RANGE_ENTRY(DRAGDROP_S),     MAKE_RANGE_ENTRY(ENUM_E),       MAKE_RANGE_ENTRY(ENUM_S),
-        MAKE_RANGE_ENTRY(INPLACE_E),      MAKE_RANGE_ENTRY(INPLACE_S),    MAKE_RANGE_ENTRY(MARSHAL_E),
-        MAKE_RANGE_ENTRY(MARSHAL_S),      MAKE_RANGE_ENTRY(MK_E),         MAKE_RANGE_ENTRY(MK_S),
-        MAKE_RANGE_ENTRY(OLEOBJ_E),       MAKE_RANGE_ENTRY(OLEOBJ_S),     MAKE_RANGE_ENTRY(OLE_E),
-        MAKE_RANGE_ENTRY(OLE_S),          MAKE_RANGE_ENTRY(REGDB_E),      MAKE_RANGE_ENTRY(REGDB_S),
-        MAKE_RANGE_ENTRY(VIEW_E),         MAKE_RANGE_ENTRY(VIEW_S),       MAKE_RANGE_ENTRY(CONNECT_E),
-        MAKE_RANGE_ENTRY(CONNECT_S),
+        MAKE_RANGE_ENTRY((LONG)CACHE_E),        MAKE_RANGE_ENTRY((LONG)CACHE_S),      MAKE_RANGE_ENTRY((LONG)CLASSFACTORY_E),
+        MAKE_RANGE_ENTRY((LONG)CLASSFACTORY_S), MAKE_RANGE_ENTRY((LONG)CLIENTSITE_E), MAKE_RANGE_ENTRY((LONG)CLIENTSITE_S),
+        MAKE_RANGE_ENTRY((LONG)CLIPBRD_E),      MAKE_RANGE_ENTRY((LONG)CLIPBRD_S),    MAKE_RANGE_ENTRY((LONG)CONVERT10_E),
+        MAKE_RANGE_ENTRY((LONG)CONVERT10_S),    MAKE_RANGE_ENTRY((LONG)CO_E),         MAKE_RANGE_ENTRY((LONG)CO_S),
+        MAKE_RANGE_ENTRY((LONG)DATA_E),         MAKE_RANGE_ENTRY((LONG)DATA_S),       MAKE_RANGE_ENTRY((LONG)DRAGDROP_E),
+        MAKE_RANGE_ENTRY((LONG)DRAGDROP_S),     MAKE_RANGE_ENTRY((LONG)ENUM_E),       MAKE_RANGE_ENTRY((LONG)ENUM_S),
+        MAKE_RANGE_ENTRY((LONG)INPLACE_E),      MAKE_RANGE_ENTRY((LONG)INPLACE_S),    MAKE_RANGE_ENTRY((LONG)MARSHAL_E),
+        MAKE_RANGE_ENTRY((LONG)MARSHAL_S),      MAKE_RANGE_ENTRY((LONG)MK_E),         MAKE_RANGE_ENTRY((LONG)MK_S),
+        MAKE_RANGE_ENTRY((LONG)OLEOBJ_E),       MAKE_RANGE_ENTRY((LONG)OLEOBJ_S),     MAKE_RANGE_ENTRY((LONG)OLE_E),
+        MAKE_RANGE_ENTRY((LONG)OLE_S),          MAKE_RANGE_ENTRY((LONG)REGDB_E),      MAKE_RANGE_ENTRY((LONG)REGDB_S),
+        MAKE_RANGE_ENTRY((LONG)VIEW_E),         MAKE_RANGE_ENTRY((LONG)VIEW_S),       MAKE_RANGE_ENTRY((LONG)CONNECT_E),
+        MAKE_RANGE_ENTRY((LONG)CONNECT_S),
 
     };
 #undef MAKE_RANGE_ENTRY
diff --git a/com/win32com/src/MiscTypes.cpp b/com/win32com/src/MiscTypes.cpp
index 64808d6..82bb805 100644
--- a/com/win32com/src/MiscTypes.cpp
+++ b/com/win32com/src/MiscTypes.cpp
@@ -288,7 +288,7 @@ PyTypeObject PyOleArgNotFoundType = {
 BOOL PyObject_AsOLEMENUGROUPWIDTHS(PyObject *oblpMenuWidths, OLEMENUGROUPWIDTHS *pWidths)
 {
     return PyArg_ParseTuple(oblpMenuWidths, "iiiiii", &pWidths->width[0], &pWidths->width[1], &pWidths->width[2],
-                            &pWidths->width[3], &pWidths->width[4], &pWidths->width[5]) != NULL;
+                            &pWidths->width[3], &pWidths->width[4], &pWidths->width[5]) != 0;
 }
 
 PyObject *PyObject_FromOLEMENUGROUPWIDTHS(const OLEMENUGROUPWIDTHS *pWidths)
diff --git a/com/win32com/src/PyIUnknown.cpp b/com/win32com/src/PyIUnknown.cpp
index 1473cb8..6221fb3 100644
--- a/com/win32com/src/PyIUnknown.cpp
+++ b/com/win32com/src/PyIUnknown.cpp
@@ -31,7 +31,11 @@ PyObject *PyIUnknown::repr()
 {
     // @comm The repr of this object displays both the object's address, and its attached IUnknown's address
     char buf[256];
+#ifdef _MSC_VER
     _snprintf(buf, 256, "<%hs at 0x%0p with obj at 0x%0p>", ob_type->tp_name, this, m_obj);
+#else
+    _snprintf(buf, 256, "<%s at 0x%p with obj at 0x%p>", ob_type->tp_name, this, m_obj);
+#endif
     return PyUnicode_FromString(buf);
 }
 
diff --git a/com/win32com/src/PyRecord.cpp b/com/win32com/src/PyRecord.cpp
index 394d15b..7811731 100644
--- a/com/win32com/src/PyRecord.cpp
+++ b/com/win32com/src/PyRecord.cpp
@@ -504,7 +504,7 @@ static void _FreeFieldNames(BSTR *strings, ULONG num_names)
     delete[] strings;
 }
 
-void PyWinCoreString_Concat(register PyObject **pv, register PyObject *w)
+void PyWinCoreString_Concat(PyObject **pv, PyObject *w)
 {
     if (!w) {  // hrm - string version doesn't do this, but I saw PyObject_Repr() return NULL...
         Py_XDECREF(*pv);
@@ -516,7 +516,7 @@ void PyWinCoreString_Concat(register PyObject **pv, register PyObject *w)
     *pv = tmp;
 }
 
-void PyWinCoreString_ConcatAndDel(register PyObject **pv, register PyObject *w)
+void PyWinCoreString_ConcatAndDel(PyObject **pv, PyObject *w)
 {
     PyWinCoreString_Concat(pv, w);
     Py_XDECREF(w);
diff --git a/com/win32com/src/dllmain.cpp b/com/win32com/src/dllmain.cpp
index de857ed..d9a7ed3 100644
--- a/com/win32com/src/dllmain.cpp
+++ b/com/win32com/src/dllmain.cpp
@@ -125,7 +125,7 @@ extern "C" __declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD
         **       tell us).
         */
 
-        /* We don't assume anything about Python's init state here!
+        /* We don't assume anything about Python's init state here! */
 
         /*
         ** we don't need to be notified about threads
diff --git a/com/win32com/src/extensions/PyIPropertySetStorage.cpp b/com/win32com/src/extensions/PyIPropertySetStorage.cpp
index 8f8b96c..fb000df 100644
--- a/com/win32com/src/extensions/PyIPropertySetStorage.cpp
+++ b/com/win32com/src/extensions/PyIPropertySetStorage.cpp
@@ -172,7 +172,7 @@ STDMETHODIMP PyGPropertySetStorage::Create(
         TmpPyObject obfmtid = PyWinObject_FromIID(rfmtid);
         if (obfmtid == NULL)
             return MAKE_PYCOM_GATEWAY_FAILURE_CODE("Create");
-        hr = InvokeViaPolicy("Create", &result, "OOkk", obfmtid, obclsid, grfFlags, grfMode);
+        hr = InvokeViaPolicy("Create", &result, "OOkk", &obfmtid, &obclsid, grfFlags, grfMode);
     }
     if (FAILED(hr))
         return hr;
@@ -195,7 +195,7 @@ STDMETHODIMP PyGPropertySetStorage::Open(
     if (ppprstg == NULL)
         return E_POINTER;
     PyObject *result;
-    HRESULT hr = InvokeViaPolicy("Open", &result, "Ok", obfmtid, grfMode);
+    HRESULT hr = InvokeViaPolicy("Open", &result, "Ok", &obfmtid, grfMode);
     if (FAILED(hr))
         return hr;
     // Process the Python results, and convert back to the real params
diff --git a/com/win32com/src/extensions/PyIPropertyStorage.cpp b/com/win32com/src/extensions/PyIPropertyStorage.cpp
index bbc2c07..7f7b482 100644
--- a/com/win32com/src/extensions/PyIPropertyStorage.cpp
+++ b/com/win32com/src/extensions/PyIPropertyStorage.cpp
@@ -950,7 +950,7 @@ STDMETHODIMP PyGPropertyStorage::WriteMultiple(
         TmpPyObject obpropvars = PyObject_FromPROPVARIANTs((PROPVARIANT *)rgpropvar, cpspec);
         if (obpropvars == NULL)
             return MAKE_PYCOM_GATEWAY_FAILURE_CODE("WriteMultiple");
-        hr = InvokeViaPolicy("WriteMultiple", NULL, "OOk", obpropspecs, obpropvars, propidNameFirst);
+        hr = InvokeViaPolicy("WriteMultiple", NULL, "OOk", &obpropspecs, &obpropvars, propidNameFirst);
     }
     return hr;
 }
@@ -1044,7 +1044,7 @@ STDMETHODIMP PyGPropertyStorage::WritePropertyNames(
         TmpPyObject obnames = PyWinObject_FromWCHARArray(rglpwstrName, cpropid);
         if (obnames == NULL)
             return MAKE_PYCOM_GATEWAY_FAILURE_CODE("WritePropertyNames");
-        return InvokeViaPolicy("WritePropertyNames", NULL, "OO", obpropids, obnames);
+        return InvokeViaPolicy("WritePropertyNames", NULL, "OO", &obpropids, &obnames);
     }
 }
 
@@ -1129,7 +1129,7 @@ STDMETHODIMP PyGPropertyStorage::SetTimes(
             Py_INCREF(Py_None);
             obmtime = Py_None;
         }
-        hr = InvokeViaPolicy("SetTimes", NULL, "OOO", obctime, obatime, obmtime);
+        hr = InvokeViaPolicy("SetTimes", NULL, "OOO", &obctime, &obatime, &obmtime);
     }
     return hr;
 }
diff --git a/com/win32com/src/include/PythonCOM.h b/com/win32com/src/include/PythonCOM.h
index 2bb531f..538d28d 100644
--- a/com/win32com/src/include/PythonCOM.h
+++ b/com/win32com/src/include/PythonCOM.h
@@ -92,10 +92,15 @@
 
 #ifdef __MINGW32__
 // Special Mingw32 considerations.
-#define NO_PYCOM_ENUMSTATPROPSTG
 #define __try try
-#define __except catch
+#define __except(filter) catch(...)
 #include <olectl.h>
+#include <oleidl.h>
+#include <oaidl.h>
+#include <objidl.h>
+#include <mapiguid.h>
+#include <shlguid.h>
+#include <initguid.h>
 
 #endif  // __MINGW32__
 
diff --git a/com/win32com/src/univgw.cpp b/com/win32com/src/univgw.cpp
index 73616e4..1168bc6 100644
--- a/com/win32com/src/univgw.cpp
+++ b/com/win32com/src/univgw.cpp
@@ -253,7 +253,7 @@ static pfnGWMethod make_method(DWORD index, UINT argsize, UINT argc)
     }
 
     *(int *)(code + 30) = index;
-    *(void **)(code + 36) = &univgw_dispatch;
+    *(void **)(code + 36) = (void*)&univgw_dispatch;
 
     DWORD oldprotect;
     if (!VirtualProtect(code, sizeof(wrapper), PAGE_EXECUTE, &oldprotect)) {
diff --git a/com/win32comext/adsi/src/PyIADs.cpp b/com/win32comext/adsi/src/PyIADs.cpp
index 1452a5d..bd88d49 100644
--- a/com/win32comext/adsi/src/PyIADs.cpp
+++ b/com/win32comext/adsi/src/PyIADs.cpp
@@ -4,8 +4,8 @@
 // getattr for the type.
 // All "get_" methods have been exposed as properties.
 
-#include "pythoncom.h"
-#include "PyADSIutil.h"
+#include "PythonCOM.h"
+#include "PyADSIUtil.h"
 #include "PyIADs.h"
 
 // @doc - This file contains autoduck documentation
diff --git a/com/win32comext/adsi/src/PyIDirectoryObject.i b/com/win32comext/adsi/src/PyIDirectoryObject.i
index a656092..e4a4c37 100644
--- a/com/win32comext/adsi/src/PyIDirectoryObject.i
+++ b/com/win32comext/adsi/src/PyIDirectoryObject.i
@@ -120,17 +120,17 @@ PyObject *PyIDirectoryObject::CreateDSObject(PyObject *self, PyObject *args)
 	if (!PyArg_ParseTuple(args, "OO:CreateDSObject", &obName, &obAttr))
 		return NULL;
 
-    WCHAR *szName= NULL;
-    if (!PyWinObject_AsWCHAR(obName, &szName, FALSE))
-        return NULL;
+	WCHAR *szName= NULL;
+	if (!PyWinObject_AsWCHAR(obName, &szName, FALSE))
+		return NULL;
 
 	PADS_ATTR_INFO attr;
 	DWORD cattr;
 	if (!PyADSIObject_AsADS_ATTR_INFOs(obAttr, &attr, &cattr)) {
-        PyWinObject_FreeWCHAR(szName);
+		PyWinObject_FreeWCHAR(szName);
 		return NULL;
-    }
-    IDispatch *pRet = NULL;
+	}
+	IDispatch *pRet = NULL;
 
 	Py_BEGIN_ALLOW_THREADS
 	_result = (HRESULT )_swig_self->CreateDSObject(szName, attr, cattr, &pRet);
diff --git a/com/win32comext/adsi/src/PyIDirectorySearch.i b/com/win32comext/adsi/src/PyIDirectorySearch.i
index f32aec8..2d56186 100644
--- a/com/win32comext/adsi/src/PyIDirectorySearch.i
+++ b/com/win32comext/adsi/src/PyIDirectorySearch.i
@@ -81,9 +81,9 @@ PyObject *PyIDirectorySearch::ExecuteSearch(PyObject *self, PyObject *args)
 	// @pyparm [<o PyUnicode>, ...]|attrNames||
 	if (!PyArg_ParseTuple(args, "OO", &obFilter, &obNames))
 		return NULL;
-    WCHAR *szFilter = NULL;
-    if (!PyWinObject_AsWCHAR(obFilter, &szFilter, FALSE))
-        return NULL;
+	WCHAR *szFilter = NULL;
+	if (!PyWinObject_AsWCHAR(obFilter, &szFilter, FALSE))
+		return NULL;
 
 	WCHAR **names = NULL;
 	DWORD cnames = -1;
@@ -94,7 +94,7 @@ PyObject *PyIDirectorySearch::ExecuteSearch(PyObject *self, PyObject *args)
         }
 
 	HRESULT _result;
-    ADS_SEARCH_HANDLE handle;
+	ADS_SEARCH_HANDLE handle;
 
 	Py_BEGIN_ALLOW_THREADS
 	_result = (HRESULT )_swig_self->ExecuteSearch(szFilter, names, cnames, &handle);
@@ -106,7 +106,7 @@ PyObject *PyIDirectorySearch::ExecuteSearch(PyObject *self, PyObject *args)
         ret = PyLong_FromSsize_t((Py_ssize_t)handle);
 	}
 	PyADSI_FreeNames(names, cnames);
-    PyWinObject_FreeWCHAR(szFilter);
+	PyWinObject_FreeWCHAR(szFilter);
 	return ret;
 }
 
diff --git a/com/win32comext/adsi/src/adsilib.i b/com/win32comext/adsi/src/adsilib.i
index fa74a61..c5ad193 100644
--- a/com/win32comext/adsi/src/adsilib.i
+++ b/com/win32comext/adsi/src/adsilib.i
@@ -1,7 +1,12 @@
 /* ADSI SWIG Support */
 
+typedef VARIANT VARIANT;
+typedef ADS_OBJECT_INFO ADS_OBJECT_INFO;
+typedef IDataObject IDataObject;
+typedef IDispatch IDispatch;
+
 %{
-#include "pyadsiutil.h"
+#include "PyADSIUtil.h"
 
 extern PyObject *OleSetADSIError(HRESULT hr, IUnknown *pUnk, REFIID iid);
 %}
diff --git a/com/win32comext/axcontrol/src/PyIOleInPlaceSiteWindowless.cpp b/com/win32comext/axcontrol/src/PyIOleInPlaceSiteWindowless.cpp
index 4e6c0e4..c35fd36 100644
--- a/com/win32comext/axcontrol/src/PyIOleInPlaceSiteWindowless.cpp
+++ b/com/win32comext/axcontrol/src/PyIOleInPlaceSiteWindowless.cpp
@@ -394,7 +394,7 @@ STDMETHODIMP PyGOleInPlaceSiteWindowless::InvalidateRgn(
     /* [in] */ BOOL fErase)
 {
     PY_GATEWAY_METHOD;
-    HRESULT hr = InvokeViaPolicy("InvalidateRgn", NULL, "li", (long)hRGN, fErase);
+    HRESULT hr = InvokeViaPolicy("InvalidateRgn", NULL, "li", (LONG_PTR)hRGN, fErase);
     return hr;
 }
 
diff --git a/com/win32comext/axcontrol/src/PyIViewObject.cpp b/com/win32comext/axcontrol/src/PyIViewObject.cpp
index 5d66cbb..5d7db00 100644
--- a/com/win32comext/axcontrol/src/PyIViewObject.cpp
+++ b/com/win32comext/axcontrol/src/PyIViewObject.cpp
@@ -256,7 +256,7 @@ STDMETHODIMP PyGViewObject::Draw(
         Py_BuildValue("llll", lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom);
     if (oblprcWBounds == NULL)
         return PyCom_HandlePythonFailureToCOM();
-    PyObject *obFuncContinue = PyLong_FromVoidPtr(pfnContinue);
+    PyObject *obFuncContinue = PyLong_FromVoidPtr((PVOID)pfnContinue);
     if (obFuncContinue == NULL)
         return PyCom_HandlePythonFailureToCOM();
     PyObject *obContinue = PyWinObject_FromULONG_PTR(dwContinue);
diff --git a/com/win32comext/ifilter/src/stdafx.h b/com/win32comext/ifilter/src/stdafx.h
index 0982841..dd35abd 100644
--- a/com/win32comext/ifilter/src/stdafx.h
+++ b/com/win32comext/ifilter/src/stdafx.h
@@ -13,7 +13,9 @@
 #include <Filter.h>
 #include <Filterr.h>
 
+#ifndef __MINGW32__
 #define MISSING_PROPSTG
+#endif
 #ifdef MISSING_PROPSTG
 // Ack - NTQuery.h is failing with the Vista SDK - pull in what we need
 // Problem is missing propstg.h, and all the work-arounds are uglier than
diff --git a/com/win32comext/mapi/src/mapiutil.cpp b/com/win32comext/mapi/src/mapiutil.cpp
index b704c77..9ede990 100644
--- a/com/win32comext/mapi/src/mapiutil.cpp
+++ b/com/win32comext/mapi/src/mapiutil.cpp
@@ -1,5 +1,5 @@
 // General utilities and conversion routines for MAPI support.
-#include "pywintypes.h"
+#include "PyWinTypes.h"
 #include "PythonCOM.h"
 #include "PyMAPIUtil.h"
 // @doc
@@ -350,7 +350,7 @@ BOOL PyMAPIObject_AsSPropValue(PyObject *Valob, SPropValue *pv, void *pAllocMore
 
         default: {
             char buf[128];
-            sprintf(buf, "Unsupported MAPI property type 0x%X", PROP_TYPE(pv->ulPropTag));
+            sprintf(buf, "Unsupported MAPI property type 0x%lX", PROP_TYPE(pv->ulPropTag));
             PyErr_SetString(PyExc_TypeError, buf);
             ok = FALSE;
         }
@@ -511,7 +511,7 @@ PyObject *PyMAPIObject_FromSPropValue(SPropValue *pv)
             break;
 
         default:
-            printf("File %s: Unsupported MAPI property type 0x%X", __FILE__, PROP_TYPE(pv->ulPropTag));
+            printf("File %s: Unsupported MAPI property type 0x%lX", __FILE__, PROP_TYPE(pv->ulPropTag));
             /* Don't set exception, as this prevents otherwise valid props from
                being returned
             */
diff --git a/com/win32comext/mapi/src/PyIAddrBook.i b/com/win32comext/mapi/src/PyIAddrBook.i
index de09011..7f1f2c5 100644
--- a/com/win32comext/mapi/src/PyIAddrBook.i
+++ b/com/win32comext/mapi/src/PyIAddrBook.i
@@ -39,14 +39,14 @@ HRESULT ResolveName(
 // @pyswig <o PyIInterface>|OpenEntry|Opens a folder or message and returns an interface object for further access.
 PyObject *PyIAddrBook::OpenEntry(PyObject *self, PyObject *args)
 {
-    HRESULT  _result;
-    char * entryString;
+	HRESULT  _result;
+	char * entryString;
 	int entryStrLen;
-    IID iid;
+	IID iid;
 	IID *pIID;
-    PyObject * objIID = 0;
-    unsigned long  flags;
-    IUnknown * pUnk = NULL;
+	PyObject * objIID = 0;
+	unsigned long  flags;
+	IUnknown * pUnk = NULL;
 	ULONG resType;
 	PyObject *obEntry;
 
@@ -55,8 +55,8 @@ PyObject *PyIAddrBook::OpenEntry(PyObject *self, PyObject *args)
 	// @pyparm string|entryId||The entryID of the object
 	// @pyparm <o PyIID>|iid||The IID of the object to return, or None for the default IID
 	// @pyparm int|flags||Bitmask of flags that controls how the object is opened.
-    if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags))
-        return NULL;
+	if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags))
+		return NULL;
 	if (obEntry==Py_None) {
 		entryString = NULL;
 		entryStrLen = 0;
@@ -75,12 +75,12 @@ PyObject *PyIAddrBook::OpenEntry(PyObject *self, PyObject *args)
 			return NULL;
 	}
 	Py_BEGIN_ALLOW_THREADS
-     _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk);
+	_result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk);
 	Py_END_ALLOW_THREADS
-     if (FAILED(_result)) {
-           return OleSetOleError(_result);
-     }
-	 return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/);
+	if (FAILED(_result)) {
+		return OleSetOleError(_result);
+	}
+	return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/);
 }
 %}
 
@@ -101,7 +101,7 @@ PyObject *PyIAddrBook::CompareEntryIDs(PyObject *self, PyObject *args)
 	IAddrBook *_swig_self;
 	PyObject *obE1, *obE2;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
-    if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs",
+	if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs",
 		&obE1, // @pyparm string|entryId||The first entry ID to be compared
 		&obE2, // @pyparm string|entryId||The second entry ID to be compared
 		&flags)) // @pyparm int|flags|0|Reserved - must be zero.
diff --git a/com/win32comext/mapi/src/PyIAttach.i b/com/win32comext/mapi/src/PyIAttach.i
index a80c4f0..dd1eb5f 100644
--- a/com/win32comext/mapi/src/PyIAttach.i
+++ b/com/win32comext/mapi/src/PyIAttach.i
@@ -42,10 +42,10 @@ PyObject *PyIAttach::GetLastError(PyObject *self, PyObject *args)
 	IAttach *_swig_self;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
 
-    if(!PyArg_ParseTuple(args,"l|l:GetLastError",
+	if(!PyArg_ParseTuple(args,"l|l:GetLastError",
 		&hr, // @pyparm int|hr||Contains the error code generated in the previous method call.
 		&flags)) // @pyparm int|flags||Indicates for format for the output.
-        return NULL;
+		return NULL;
 
 	Py_BEGIN_ALLOW_THREADS
 	hRes = _swig_self->GetLastError(hr, flags, &me);
diff --git a/com/win32comext/mapi/src/PyIConverterSession.i b/com/win32comext/mapi/src/PyIConverterSession.i
index 9496b4d..28f1984 100644
--- a/com/win32comext/mapi/src/PyIConverterSession.i
+++ b/com/win32comext/mapi/src/PyIConverterSession.i
@@ -72,9 +72,9 @@ PyObject *PyIConverterSession::MIMEToMAPI(PyObject *self, PyObject *args)
 	IMessage *pMsg = NULL;
 
 	if (!PyCom_InterfaceFromPyObject(obStream, IID_IStream, (void **)&pStream, FALSE))
-		goto done;
+		if (pStream) pStream->Release();
 	if (!PyCom_InterfaceFromPyObject(obMsg, IID_IMessage, (void **)&pMsg, FALSE))
-		goto done;
+		if (pMsg) pMsg->Release();
 
 	{
 		PY_INTERFACE_PRECALL;
@@ -90,12 +90,6 @@ PyObject *PyIConverterSession::MIMEToMAPI(PyObject *self, PyObject *args)
 		result = Py_None;
 	}
 
-done:
-	if (pStream)
-		pStream->Release();
-	if (pMsg)
-		pMsg->Release();
-
 	return result;
 }
 
@@ -117,9 +111,9 @@ PyObject *PyIConverterSession::MAPIToMIMEStm(PyObject *self, PyObject *args)
 	IMessage *pMsg = NULL;
 
 	if (!PyCom_InterfaceFromPyObject(obMsg, IID_IMessage, (void **)&pMsg, FALSE))
-		goto done;
+		if (pMsg) pMsg->Release();
 	if (!PyCom_InterfaceFromPyObject(obStream, IID_IStream, (void **)&pStream, FALSE))
-		goto done;
+		if (pStream) pStream->Release();
 
 	{
 		PY_INTERFACE_PRECALL;
@@ -135,12 +129,6 @@ PyObject *PyIConverterSession::MAPIToMIMEStm(PyObject *self, PyObject *args)
 		result = Py_None;
 	}
 
-done:
-	if (pStream)
-		pStream->Release();
-	if (pMsg)
-		pMsg->Release();
-
 	return result;
 }
 
diff --git a/com/win32comext/mapi/src/PyIMAPIContainer.i b/com/win32comext/mapi/src/PyIMAPIContainer.i
index 04e2192..e351441 100644
--- a/com/win32comext/mapi/src/PyIMAPIContainer.i
+++ b/com/win32comext/mapi/src/PyIMAPIContainer.i
@@ -30,14 +30,14 @@ PyIMAPIContainer::~PyIMAPIContainer()
 // @pyswig <o PyIInterface>|OpenEntry|Opens an object and returns an interface object for further access.
 PyObject *PyIMAPIContainer::OpenEntry(PyObject *self, PyObject *args)
 {
-    HRESULT  _result;
-    char * entryString;
+	HRESULT  _result;
+	char * entryString;
 	int entryStrLen;
-    IID iid;
+	IID iid;
 	IID *pIID;
-    PyObject * objIID = 0;
-    unsigned long  flags;
-    IUnknown * pUnk = NULL;
+	PyObject * objIID = 0;
+	unsigned long  flags;
+	IUnknown * pUnk = NULL;
 	ULONG resType;
 	PyObject *obEntry;
 
@@ -46,8 +46,8 @@ PyObject *PyIMAPIContainer::OpenEntry(PyObject *self, PyObject *args)
     // @pyparm string|entryId||The EntryID to open.
     // @pyparm <o PyIID>|iid||The IID of the returned interface, or None for the default interface.
     // @pyparm int|flags||Flags for the call.  May include MAPI_BEST_ACCESS, MAPI_DEFERRED_ERRORS, MAPI_MODIFY and possibly others (see the MAPI documentation)
-    if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags))
-        return NULL;
+	if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags))
+		return NULL;
 	if (obEntry==Py_None) {
 		entryString = NULL;
 		entryStrLen = 0;
@@ -66,12 +66,12 @@ PyObject *PyIMAPIContainer::OpenEntry(PyObject *self, PyObject *args)
 			return NULL;
 	}
 	Py_BEGIN_ALLOW_THREADS
-     _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk);
+	_result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk);
 	Py_END_ALLOW_THREADS
-     if (FAILED(_result)) {
-           return OleSetOleError(_result);
-     }
-	 return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/);
+	if (FAILED(_result)) {
+		return OleSetOleError(_result);
+	}
+	return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/);
 }
 
 
diff --git a/com/win32comext/mapi/src/PyIMAPIFolder.i b/com/win32comext/mapi/src/PyIMAPIFolder.i
index f67f8b0..89d47a4 100644
--- a/com/win32comext/mapi/src/PyIMAPIFolder.i
+++ b/com/win32comext/mapi/src/PyIMAPIFolder.i
@@ -43,10 +43,10 @@ PyObject *PyIMAPIFolder::GetLastError(PyObject *self, PyObject *args)
 	IMAPIFolder *_swig_self;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
 
-    if(!PyArg_ParseTuple(args,"l|l:GetLastError",
+	if(!PyArg_ParseTuple(args,"l|l:GetLastError",
 		&hr, // @pyparm int|hr||Contains the error code generated in the previous method call.
 		&flags)) // @pyparm int|flags||Indicates for format for the output.
-        return NULL;
+		return NULL;
 
 	Py_BEGIN_ALLOW_THREADS
 	hRes = _swig_self->GetLastError(hr, flags, &me);
@@ -156,12 +156,12 @@ PyObject *PyIMAPIFolder::DeleteFolder(PyObject *self, PyObject *args)
 	IMAPIFolder *_swig_self;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
 
-    if(!PyArg_ParseTuple(args,"OOO|l:DeleteFolder",
+	if(!PyArg_ParseTuple(args,"OOO|l:DeleteFolder",
 		&obEntryId, // @pyparm string|entryId||The EntryID of the subfolder to delete.
 		&obUIParam, // @pyparm long|uiParam||Handle of the parent window of the progress indicator.
 		&obProgress, // @pyparm <o PyIMAPIProgress>|progress||A progress object, or None
 		&flags))
-        return NULL;
+		return NULL;
 	if (PyBytes_Check(obEntryId)) {
 		eid = (LPENTRYID)PyBytes_AsString(obEntryId);
 		cbEID = PyBytes_Size(obEntryId);
diff --git a/com/win32comext/mapi/src/PyIMAPIProp.i b/com/win32comext/mapi/src/PyIMAPIProp.i
index 65dea9a..5d9eac7 100644
--- a/com/win32comext/mapi/src/PyIMAPIProp.i
+++ b/com/win32comext/mapi/src/PyIMAPIProp.i
@@ -46,19 +46,19 @@ PyObject *PyIMAPIProp::GetProps(PyObject *self, PyObject *args) {
 	if ((_swig_self=GetI(self))==NULL) return NULL;
 	// @pyparm <o PySPropTagArray>|propList||The list of properties
 	// @pyparm int|flags|0|
-    if(!PyArg_ParseTuple(args,"O|l:GetProps",&_obj0,&_arg1))
-        return NULL;
+	if(!PyArg_ParseTuple(args,"O|l:GetProps",&_obj0,&_arg1))
+		return NULL;
 	if (!PyMAPIObject_AsSPropTagArray(_obj0, &_arg0))
 		return NULL;
 	ULONG numValues;
 	SPropValue *pv;
 	Py_BEGIN_ALLOW_THREADS
-    _result = (HRESULT )_swig_self->GetProps(_arg0,_arg1, &numValues, &pv);
+	_result = (HRESULT )_swig_self->GetProps(_arg0,_arg1, &numValues, &pv);
 	Py_END_ALLOW_THREADS
 	PyMAPIObject_FreeSPropTagArray(_arg0);
-    if (FAILED(_result))  {
-       return OleSetOleError(_result);
-    }
+	if (FAILED(_result))  {
+		return OleSetOleError(_result);
+	}
 
 	_resultobj = PyTuple_New(numValues);
 	if (_resultobj==NULL) {
@@ -86,7 +86,7 @@ PyObject *PyIMAPIProp::GetProps(PyObject *self, PyObject *args) {
 PyObject *PyIMAPIProp::DeleteProps(PyObject *self, PyObject *args)
 {
 	PyObject *obs;
-    SPropTagArray * _arg0;
+	SPropTagArray * _arg0;
 	HRESULT hr;
 	IMAPIProp *pMAPIProp;
 	PyObject *obWantProblems = Py_False;
@@ -94,7 +94,7 @@ PyObject *PyIMAPIProp::DeleteProps(PyObject *self, PyObject *args)
 	if ((pMAPIProp=GetI(self))==NULL) return NULL;
 	// @pyparm <o PySPropTagArray>|propList||The list of properties
 	// @pyparm bool|wantProblems|False|Return detailed error information
-    if(!PyArg_ParseTuple(args,"O|O:DeleteProps",&obs, &obWantProblems))
+	if(!PyArg_ParseTuple(args,"O|O:DeleteProps",&obs, &obWantProblems))
 		return NULL;
 	int wantProblems = PyObject_IsTrue(obWantProblems);
 	if (wantProblems == -1)
@@ -128,7 +128,7 @@ PyObject *PyIMAPIProp::SetProps(PyObject *self, PyObject *args)
 	if ((pMAPIProp=GetI(self))==NULL) return NULL;
 	// @pyparm [<o PySPropValue>, ]|propList||The list of properties
 	// @pyparm bool|wantProblems|False|Return detailed error information
-    if(!PyArg_ParseTuple(args,"O|O:SetProps",&obs, &obWantProblems))
+	if(!PyArg_ParseTuple(args,"O|O:SetProps",&obs, &obWantProblems))
 		return NULL;
 	if (!PySequence_Check(obs)) {
 		PyErr_SetString(PyExc_TypeError, "Properties must be a sequence of tuples");
@@ -183,7 +183,7 @@ PyObject *PyIMAPIProp::CopyTo(PyObject *self, PyObject *args)
 	// @pyparm <o PyIMAPIProp>|dest||The destination object
 	// @pyparm int|flags||flags
 	// @pyparm bool|wantProblems|False|Return detailed error information
-    if(!PyArg_ParseTuple(args,"OOlzOOl|O:CopyTo",&obIIDExclude, &obPropTags, &ulUIParam, &szIgnore, &obIID, &obDest, &flags, &obWantProblems))
+	if(!PyArg_ParseTuple(args,"OOlzOOl|O:CopyTo",&obIIDExclude, &obPropTags, &ulUIParam, &szIgnore, &obIID, &obDest, &flags, &obWantProblems))
 		return NULL;
 	int wantProblems = PyObject_IsTrue(obWantProblems);
 	if (wantProblems == -1)
@@ -264,7 +264,7 @@ PyObject *PyIMAPIProp::CopyProps(PyObject *self, PyObject *args)
 	// @pyparm <o PyIMAPIProp>|dest||The destination object
 	// @pyparm int|flags||flags
 	// @pyparm bool|wantProblems|False|Return detailed error information
-    if(!PyArg_ParseTuple(args,"OlzOOl|O:CopyProps",&obPropTags, &ulUIParam, &szIgnore, &obIID, &obDest, &flags, &obWantProblems))
+	if(!PyArg_ParseTuple(args,"OlzOOl|O:CopyProps",&obPropTags, &ulUIParam, &szIgnore, &obIID, &obDest, &flags, &obWantProblems))
 		return NULL;
 	int wantProblems = PyObject_IsTrue(obWantProblems);
 	if (wantProblems == -1)
@@ -314,7 +314,7 @@ PyObject *PyIMAPIProp::OpenProperty(PyObject *self, PyObject *args)
 	// @pyparm <o PyIID>|iid||The IID of the resulting interface.
 	// @pyparm int|interfaceOptions||Data that relates to the interface identified by the lpiid parameter.
 	// @pyparm int|flags||flags
-    if(!PyArg_ParseTuple(args,"kOll:OpenProperty",&propTag, &obIID, &interfaceOptions, &flags))
+	if(!PyArg_ParseTuple(args,"kOll:OpenProperty",&propTag, &obIID, &interfaceOptions, &flags))
 		return NULL;
 	// IID.
 	if (!PyWinObject_AsIID(obIID, &iid))
@@ -418,10 +418,10 @@ PyObject *PyIMAPIProp::GetLastError(PyObject *self, PyObject *args)
 	IMAPIProp *_swig_self;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
 
-    if(!PyArg_ParseTuple(args,"l|l:GetLastError",
+	if(!PyArg_ParseTuple(args,"l|l:GetLastError",
 		&hr, // @pyparm int|hr||Contains the error code generated in the previous method call.
 		&flags)) // @pyparm int|flags||Indicates for format for the output.
-        return NULL;
+		return NULL;
 
 	Py_BEGIN_ALLOW_THREADS
 	hRes = _swig_self->GetLastError(hr, flags, &me);
diff --git a/com/win32comext/mapi/src/PyIMAPISession.i b/com/win32comext/mapi/src/PyIMAPISession.i
index 293d36c..f51e053 100644
--- a/com/win32comext/mapi/src/PyIMAPISession.i
+++ b/com/win32comext/mapi/src/PyIMAPISession.i
@@ -35,14 +35,14 @@ PyIMAPISession::~PyIMAPISession()
 // @pyswig <o PyIInterface>|OpenEntry|Opens an object and returns an interface object for further access.
 PyObject *PyIMAPISession::OpenEntry(PyObject *self, PyObject *args)
 {
-    HRESULT  _result;
-    char *entryString;
+	HRESULT  _result;
+	char *entryString;
 	int entryStrLen;
-    IID iid;
+	IID iid;
 	IID *pIID;
-    PyObject * objIID = 0;
-    unsigned long  flags;
-    IUnknown * pUnk = NULL;
+	PyObject * objIID = 0;
+	unsigned long  flags;
+	IUnknown * pUnk = NULL;
 	ULONG resType;
 	PyObject *obEntry;
 
@@ -51,8 +51,8 @@ PyObject *PyIMAPISession::OpenEntry(PyObject *self, PyObject *args)
     // @pyparm string|entryId||The EntryID to open.
     // @pyparm <o PyIID>|iid||The IID of the returned interface, or None for the default interface.
     // @pyparm int|flags||Flags for the call.  May include MAPI_BEST_ACCESS, MAPI_DEFERRED_ERRORS, MAPI_MODIFY and possibly others (see the MAPI documentation)
-    if(!PyArg_ParseTuple(args,"OOl:OpenEntry", &obEntry, &objIID, &flags))
-        return NULL;
+	if(!PyArg_ParseTuple(args,"OOl:OpenEntry", &obEntry, &objIID, &flags))
+		return NULL;
 	if (obEntry==Py_None) {
 		entryString = NULL;
 		entryStrLen = 0;
@@ -71,11 +71,11 @@ PyObject *PyIMAPISession::OpenEntry(PyObject *self, PyObject *args)
 			return NULL;
 	}
 	Py_BEGIN_ALLOW_THREADS
-     _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk);
+	_result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk);
 	Py_END_ALLOW_THREADS
-     if (FAILED(_result)) {
-           return OleSetOleError(_result);
-     }
+	if (FAILED(_result)) {
+		return OleSetOleError(_result);
+	}
 	 return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/);
 }
 %}
@@ -85,15 +85,15 @@ PyObject *PyIMAPISession::OpenEntry(PyObject *self, PyObject *args)
 // @pyswig <o PyIUnknown>|OpenMsgStore|Opens a message store.
 PyObject *PyIMAPISession::OpenMsgStore(PyObject *self, PyObject *args)
 {
-    HRESULT  _result;
-    char * entryString;
+	HRESULT  _result;
+	char * entryString;
 	Py_ssize_t entryStrLen;
-    IID iid;
+	IID iid;
 	IID *pIID;
-    PyObject * objIID = 0;
-    unsigned long  ulParm;
-    unsigned long  flags;
-    IMsgStore * pMS = NULL;
+	PyObject * objIID = 0;
+	unsigned long  ulParm;
+	unsigned long  flags;
+	IMsgStore * pMS = NULL;
 
 	IMAPISession *_swig_self;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
@@ -101,8 +101,8 @@ PyObject *PyIMAPISession::OpenMsgStore(PyObject *self, PyObject *args)
     // @pyparm string|entryId||The entry ID of the message store to open.
     // @pyparm <o PyIID>|iid||The IID of the interface returned, or None
     // @pyparm int|flags||Options for the call.
-    if(!PyArg_ParseTuple(args,"ls#Ol:OpenMsgStore",&ulParm,&entryString,&entryStrLen, &objIID,&flags))
-        return NULL;
+	if(!PyArg_ParseTuple(args,"ls#Ol:OpenMsgStore",&ulParm,&entryString,&entryStrLen, &objIID,&flags))
+		return NULL;
 	if (objIID==Py_None)
 		pIID = NULL;
 	else {
@@ -111,13 +111,13 @@ PyObject *PyIMAPISession::OpenMsgStore(PyObject *self, PyObject *args)
 			return NULL;
 	}
 	Py_BEGIN_ALLOW_THREADS
-     _result = (HRESULT )_swig_self->OpenMsgStore(ulParm, entryStrLen,(ENTRYID *)entryString,pIID,flags,&pMS);
+	_result = (HRESULT )_swig_self->OpenMsgStore(ulParm, entryStrLen,(ENTRYID *)entryString,pIID,flags,&pMS);
 	Py_END_ALLOW_THREADS
-     if (FAILED(_result)) {
-           return OleSetOleError(_result);
-     }
-    // @comm The result is the interface specified by the IID, or IID_IMsgStore if None is used.
-     return PyCom_PyObjectFromIUnknown(pMS, pIID ? *pIID : IID_IMsgStore, FALSE /*bAddRef*/ );
+	if (FAILED(_result)) {
+		return OleSetOleError(_result);
+	}
+	// @comm The result is the interface specified by the IID, or IID_IMsgStore if None is used.
+	return PyCom_PyObjectFromIUnknown(pMS, pIID ? *pIID : IID_IMsgStore, FALSE /*bAddRef*/ );
 }
 %}
 
@@ -131,8 +131,8 @@ PyObject *PyIMAPISession::QueryIdentity(PyObject *self, PyObject *args)
 	LPENTRYID peid;
 	IMAPISession *_swig_self;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
-    if(!PyArg_ParseTuple(args,":QueryIdentity"))
-        return NULL;
+	if(!PyArg_ParseTuple(args,":QueryIdentity"))
+		return NULL;
 
 	HRESULT _result;
 	Py_BEGIN_ALLOW_THREADS
@@ -142,8 +142,8 @@ PyObject *PyIMAPISession::QueryIdentity(PyObject *self, PyObject *args)
 	if (_result==S_OK)
 		rc = PyBytes_FromStringAndSize((char *)peid, cb);
 	else if (FAILED(_result)) {
-           rc = OleSetOleError(_result);
-    } else {
+		rc = OleSetOleError(_result);
+	} else {
 		rc = Py_None;
 		Py_INCREF(Py_None);
 	}
@@ -223,7 +223,7 @@ PyObject *PyIMAPISession::CompareEntryIDs(PyObject *self, PyObject *args)
 	IMAPISession *_swig_self;
 	PyObject *obE1, *obE2;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
-    if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs",
+	if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs",
 		&obE1, // @pyparm string|entryId||The first entry ID to be compared
 		&obE2, // @pyparm string|entryId||The second entry ID to be compared
 		&flags)) // @pyparm int|flags|0|Reserved - must be zero.
@@ -263,10 +263,10 @@ PyObject *PyIMAPISession::GetLastError(PyObject *self, PyObject *args)
 	IMAPISession *_swig_self;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
 
-    if(!PyArg_ParseTuple(args,"l|l:GetLastError",
+	if(!PyArg_ParseTuple(args,"l|l:GetLastError",
 		&hr, // @pyparm int|hr||Contains the error code generated in the previous method call.
 		&flags)) // @pyparm int|flags||Indicates for format for the output.
-        return NULL;
+		return NULL;
 
 	Py_BEGIN_ALLOW_THREADS
 	hRes = _swig_self->GetLastError(hr, flags, &me);
diff --git a/com/win32comext/mapi/src/PyIMsgStore.i b/com/win32comext/mapi/src/PyIMsgStore.i
index 64fe62c..394faf8 100644
--- a/com/win32comext/mapi/src/PyIMsgStore.i
+++ b/com/win32comext/mapi/src/PyIMsgStore.i
@@ -33,14 +33,14 @@ PyIMsgStore::~PyIMsgStore()
 // @pyswig <o PyIInterface>|OpenEntry|Opens a folder or message and returns an interface object for further access.
 PyObject *PyIMsgStore::OpenEntry(PyObject *self, PyObject *args)
 {
-    HRESULT  _result;
-    char * entryString;
+	HRESULT  _result;
+	char * entryString;
 	int entryStrLen;
-    IID iid;
+	IID iid;
 	IID *pIID;
-    PyObject * objIID = 0;
-    unsigned long  flags;
-    IUnknown * pUnk = NULL;
+	PyObject * objIID = 0;
+	unsigned long  flags;
+	IUnknown * pUnk = NULL;
 	ULONG resType;
 	PyObject *obEntry;
 
@@ -49,8 +49,8 @@ PyObject *PyIMsgStore::OpenEntry(PyObject *self, PyObject *args)
 	// @pyparm string|entryId||The entryID of the object
 	// @pyparm <o PyIID>|iid||The IID of the object to return, or None for the default IID
 	// @pyparm int|flags||Bitmask of flags that controls how the object is opened.
-    if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags))
-        return NULL;
+	if(!PyArg_ParseTuple(args,"OOl:OpenEntry",&obEntry, &objIID,&flags))
+		return NULL;
 	if (obEntry==Py_None) {
 		entryString = NULL;
 		entryStrLen = 0;
@@ -69,12 +69,12 @@ PyObject *PyIMsgStore::OpenEntry(PyObject *self, PyObject *args)
 			return NULL;
 	}
 	Py_BEGIN_ALLOW_THREADS
-     _result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk);
+	_result = (HRESULT )_swig_self->OpenEntry(entryStrLen,(ENTRYID *)entryString,pIID,flags, &resType, &pUnk);
 	Py_END_ALLOW_THREADS
-     if (FAILED(_result)) {
-           return OleSetOleError(_result);
-     }
-	 return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/);
+	if (FAILED(_result)) {
+		return OleSetOleError(_result);
+	}
+	return PyMAPIObject_FromTypedUnknown( resType, pUnk, FALSE /*bAddRef*/);
 }
 
 %}
@@ -170,7 +170,7 @@ PyObject *PyIMsgStore::CompareEntryIDs(PyObject *self, PyObject *args)
 	IMsgStore *_swig_self;
 	PyObject *obE1, *obE2;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
-    if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs",
+	if(!PyArg_ParseTuple(args,"OO|i:CompareEntryIDs",
 		&obE1, // @pyparm string|entryId||The first entry ID to be compared
 		&obE2, // @pyparm string|entryId||The second entry ID to be compared
 		&flags)) // @pyparm int|flags|0|Reserved - must be zero.
@@ -208,10 +208,10 @@ PyObject *PyIMsgStore::GetLastError(PyObject *self, PyObject *args)
 	IMsgStore *_swig_self;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
 
-    if(!PyArg_ParseTuple(args,"l|l:GetLastError",
+	if(!PyArg_ParseTuple(args,"l|l:GetLastError",
 		&hr, // @pyparm int|hr||Contains the error code generated in the previous method call.
 		&flags)) // @pyparm int|flags||Indicates for format for the output.
-        return NULL;
+		return NULL;
 
 	Py_BEGIN_ALLOW_THREADS
 	hRes = _swig_self->GetLastError(hr, flags, &me);
@@ -281,11 +281,11 @@ PyObject *PyIMsgStore::Advise(PyObject *self, PyObject *args)
 	IMsgStore *_swig_self;
 	if ((_swig_self=GetI(self))==NULL) return NULL;
 
-    if(!PyArg_ParseTuple(args,"OkO:Advise",
+	if(!PyArg_ParseTuple(args,"OkO:Advise",
 		&obEntryId, // @pyparm string|entryId||entry identifier of the folder or message about which notifications should be generated, or None
 		&ulEventMask, // @pyparm int|eventMask||A mask of values that indicate the types of notification events.
 		&obAdviseSink)) // @pyparm <o PyIMAPIAdviseSink>|adviseSink||An advise sink.
-        return NULL;
+		return NULL;
 	if (obEntryId == Py_None)
 	{
 		eid = NULL;
diff --git a/com/win32comext/mapi/src/mapi.i b/com/win32comext/mapi/src/mapi.i
index 1c2d82b..0afe794 100644
--- a/com/win32comext/mapi/src/mapi.i
+++ b/com/win32comext/mapi/src/mapi.i
@@ -25,6 +25,10 @@
 %include "mapilib.i"
 
 %{
+#ifndef _MSC_VER
+#define USES_IID_IMsgServiceAdmin2
+#endif
+
 #include "mapiaux.h"
 
 #include "PythonCOMServer.h"
@@ -633,9 +637,9 @@ PyObject *PyMAPILogonEx(PyObject *self, PyObject *args)
 		return NULL;
 
 	if (!PyWinObject_AsMAPIStr(obProfileName, &lpszProfileName, ulFlags & MAPI_UNICODE, FALSE))
-		goto done;
+		PyWinObject_FreeMAPIStr(lpszProfileName, ulFlags & MAPI_UNICODE);
 	if (!PyWinObject_AsMAPIStr(obPassword, &lpszPassword, ulFlags & MAPI_UNICODE, TRUE))
-		goto done;
+		PyWinObject_FreeMAPIStr(lpszPassword, ulFlags & MAPI_UNICODE);
 
 	Py_BEGIN_ALLOW_THREADS
 	hRes = ::MAPILogonEx(ulUIParam, lpszProfileName, lpszPassword, ulFlags, &lpSession);
@@ -646,10 +650,6 @@ PyObject *PyMAPILogonEx(PyObject *self, PyObject *args)
 	else
 		MAKE_OUTPUT_INTERFACE(&lpSession, result, IID_IMAPISession);
 
-done:
-	PyWinObject_FreeMAPIStr(lpszProfileName, ulFlags & MAPI_UNICODE);
-	PyWinObject_FreeMAPIStr(lpszPassword, ulFlags & MAPI_UNICODE);
-
 	return result;
 }
 %}
@@ -791,7 +791,7 @@ PyObject *PyOpenIMsgSession(PyObject *self, PyObject *args)
 	PY_INTERFACE_POSTCALL;
 	if (FAILED(hr))
 		return OleSetOleError(hr);
-	return PyLong_FromLong((long)pSession);
+	return PyLong_FromLong((LONG_PTR)pSession);
 }
 %}
 // @pyswig |CloseIMsgSession|
@@ -799,7 +799,7 @@ PyObject *PyOpenIMsgSession(PyObject *self, PyObject *args)
 %{
 PyObject *PyCloseIMsgSession(PyObject *self, PyObject *args)
 {
-	long session = 0;
+	LONG_PTR session = 0;
 	if (!PyArg_ParseTuple(args, "l:CloseIMsgSession", &session))
 		return NULL;
 	PY_INTERFACE_PRECALL;
@@ -823,7 +823,7 @@ PyObject *PyOpenIMsgOnIStg(PyObject *self, PyObject *args)
 	long flags = 0;
 	HRESULT hr = E_FAIL;
 	PyObject *rc = NULL;
-	long lSession;
+	LONG_PTR lSession;
 
 	if (!PyArg_ParseTuple(args, "lOO|Oll:OpenIMsgOnIStg",
 		&lSession, // @pyparm object|session||
@@ -843,7 +843,7 @@ PyObject *PyOpenIMsgOnIStg(PyObject *self, PyObject *args)
 	IMessage *pRet = NULL;
 
 	if (!PyCom_InterfaceFromPyObject(obStorage, IID_IStorage, (void **)&pStorage, FALSE))
-		goto done;
+		if (pStorage) pStorage->Release();
 
 	{
 	PY_INTERFACE_PRECALL;
@@ -861,12 +861,9 @@ PyObject *PyOpenIMsgOnIStg(PyObject *self, PyObject *args)
 	}
 	if (FAILED(hr)) {
 		OleSetOleError(hr);
-		goto done;
+		if (pSupport) pSupport->Release();
 	}
 	rc = PyCom_PyObjectFromIUnknown(pRet, IID_IMessage, /*BOOL bAddRef =*/ FALSE);
-done:
-	if (pSupport) pSupport->Release();
-	if (pStorage) pStorage->Release();
 	return rc;
 }
 %}
@@ -947,7 +944,7 @@ void decodertfhtml(char *buf,unsigned int *len)
     else if (strncmp(c,"\\pntext",7)==0) {c+=7; while (c<max && *c!='}') c++;}
     else if (strncmp(c,"\\htmlrtf",8)==0)
     { c++; while (c<max && strncmp(c,"\\htmlrtf0",9)!=0) c++;
-      if (c<max) c+=9; if (*c==' ') c++;
+      if (c<max) {c+=9;} if (*c==' ') {c++;}
     }
     else if (*c=='\r' || *c=='\n') c++;
     else if (strncmp(c,"\\{",2)==0) {*d='{'; d++; c+=2;}
@@ -1045,10 +1042,10 @@ PyObject *PyOpenStreamOnFile(PyObject *self, PyObject *args)
 			return NULL;
 
 		if (!PyWinObject_AsChars(obFileName, &filename, TRUE))
-			goto done;
+			PyWinObject_FreeChars(filename);
 
 		if (!PyWinObject_AsChars(obPrefix, &prefix, TRUE))
-			goto done;
+			PyWinObject_FreeChars(prefix);
 
 		{
 			PY_INTERFACE_PRECALL;
@@ -1057,10 +1054,6 @@ PyObject *PyOpenStreamOnFile(PyObject *self, PyObject *args)
 			PY_INTERFACE_POSTCALL;
 		}
 
-	done:
-		PyWinObject_FreeChars(filename);
-		PyWinObject_FreeChars(prefix);
-
 		if (PyErr_Occurred())
 			return NULL;
 
@@ -1071,6 +1064,7 @@ PyObject *PyOpenStreamOnFile(PyObject *self, PyObject *args)
 }
 %}
 
+#ifdef _MSC_VER
 // @pyswig <o PyIStream>|OpenStreamOnFileW|Allocates and initializes an OLE IStream object to access the contents of a file.
 %native(OpenStreamOnFileW) PyOpenStreamOnFileW;
 %{
@@ -1125,6 +1119,7 @@ PyObject *PyOpenStreamOnFileW(PyObject *self, PyObject *args)
 		return PyCom_PyObjectFromIUnknown(pStream, IID_IStream, FALSE);
 }
 %}
+#endif
 
 // @pyswig item|HrGetOneProp|Retrieves the value of a single property from an IMAPIProp object.
 %native(HrGetOneProp) PyHrGetOneProp;
@@ -1144,7 +1139,7 @@ PyObject *PyHrGetOneProp(PyObject *self, PyObject *args)
 		return NULL;
 
 	if (!PyCom_InterfaceFromPyObject(obProp, IID_IMAPIProp, (void **)&pProp, FALSE))
-		goto done;
+		if (pProp) pProp->Release();
 
 	{
 		PY_INTERFACE_PRECALL;
@@ -1154,10 +1149,10 @@ PyObject *PyHrGetOneProp(PyObject *self, PyObject *args)
 	if (FAILED(hRes))
 	{
 		OleSetOleError(hRes);
-		goto done;
+		if (pProp) pProp->Release();
 	}
 	if ((ret = PyMAPIObject_FromSPropValue(pPV)) == NULL)
-		goto done;
+		MAPIFreeBuffer(pPV);
 
 	// PyMAPIObject_FromSPropValue does not raise an exception for types
 	// it cannot handle so that GetProps doesn't blow up. Since we are processing
@@ -1166,14 +1161,11 @@ PyObject *PyHrGetOneProp(PyObject *self, PyObject *args)
 		PyLong_AsUnsignedLong(PyTuple_GET_ITEM(ret, 0)) != PT_NULL)
 	{
 		char buf[128];
-		sprintf(buf, "Unsupported MAPI property type 0x%X", PROP_TYPE(pPV->ulPropTag));
+		sprintf(buf, "Unsupported MAPI property type 0x%luX", PROP_TYPE(pPV->ulPropTag));
 		PyErr_SetString(PyExc_TypeError, buf);
 		Py_DECREF(ret);
 		ret = NULL;
 	}
-done:
-	if (pProp) pProp->Release();
-	MAPIFreeBuffer(pPV);
 
 	return ret;
 }
@@ -1187,6 +1179,7 @@ PyObject *PyHrSetOneProp(PyObject *self, PyObject *args)
 	HRESULT hRes;
 	PyObject *obProp;
 	PyObject *obPropValue;
+	ULONG propTag;
 	IMAPIProp *pProp = NULL;
 	PyObject *ret = NULL;
 	SPropValue *pPV = NULL;
@@ -1197,14 +1190,14 @@ PyObject *PyHrSetOneProp(PyObject *self, PyObject *args)
 		return NULL;
 
 	if (!PyCom_InterfaceFromPyObject(obProp, IID_IMAPIProp, (void **)&pProp, FALSE))
-		goto done;
+		if (pProp) pProp->Release();
 	if (S_OK != (hRes=MAPIAllocateBuffer(sizeof(SPropValue), (void **)&pPV)))
 	{
 		OleSetOleError(hRes);
-		goto done;
+		MAPIFreeBuffer(pPV);
 	}
 	if (!PyMAPIObject_AsSPropValue(obPropValue, pPV, pPV))
-		goto done;
+		MAPIFreeBuffer(pPV);
 
 	{
 		PY_INTERFACE_PRECALL;
@@ -1214,13 +1207,10 @@ PyObject *PyHrSetOneProp(PyObject *self, PyObject *args)
 	if (FAILED(hRes))
 	{
 		OleSetOleError(hRes);
-		goto done;
+		if (pProp) pProp->Release();
 	}
 	Py_INCREF(Py_None);
 	ret = Py_None;
-done:
-	if (pProp) pProp->Release();
-	MAPIFreeBuffer(pPV);
 
 	return ret;
 }
diff --git a/com/win32comext/mapi/src/mapilib.i b/com/win32comext/mapi/src/mapilib.i
index 266efb6..15ae650 100644
--- a/com/win32comext/mapi/src/mapilib.i
+++ b/com/win32comext/mapi/src/mapilib.i
@@ -1,12 +1,35 @@
 /* MAPI Support */
 
 %{
-#include "pymapiutil.h"
+#include "PyMAPIUtil.h"
 %}
 
 typedef unsigned long BOOKMARK;
 %apply unsigned long {BOOKMARK};
 
+typedef IID IID;
+typedef MAPIUID MAPIUID;
+typedef MAPIINIT_0 MAPIINIT_0;
+typedef IMAPISession IMAPISession;
+typedef IMAPITable IMAPITable;
+typedef IMAPIProp IMAPIProp;
+typedef IMAPIFolder IMAPIFolder;
+typedef IMAPIProgress IMAPIProgress;
+typedef IMAPIAdviseSink IMAPIAdviseSink;
+typedef IAddrBook IAddrBook;
+typedef IAttach IAttach;
+typedef IProfAdmin IProfAdmin;
+typedef IProfSect IProfSect;
+typedef IProviderAdmin IProviderAdmin;
+typedef IMsgServiceAdmin IMsgServiceAdmin;
+typedef IStream IStream;
+typedef IMessage IMessage;
+typedef IMsgStore IMsgStore;
+typedef SRowSet SRowSet;
+typedef SPropTagArray SPropTagArray;
+typedef SRestriction SRestriction;
+typedef SSortOrderSet SSortOrderSet;
+typedef SBinaryArray SBinaryArray;
 // A MAPIUID is close enough to an IID for now!
 %typemap(python,in) MAPIUID *INPUT(MAPIUID temp)
 {
