diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index cdfe349..b677178 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -25,7 +25,6 @@
 #include <config.h>
 #endif
 
-#include <pthread.h>
 #include <string.h>
 #include <time.h>
 
@@ -57,7 +56,7 @@
 #include "camel-mapi-summary.h"
 #include "camel-mapi-utils.h"
 
-#define DEBUG_FN( ) printf("----%u %s\n", (unsigned int)pthread_self(), __FUNCTION__);
+#define DEBUG_FN( ) printf("----%p %s\n", g_thread_self(), G_STRFUNC);
 #define SUMMARY_FETCH_BATCH_COUNT 150
 #define d(x)
 
diff --git a/src/camel/camel-private.h b/src/camel/camel-private.h
index 3425f93..fff6a42 100644
--- a/src/camel/camel-private.h
+++ b/src/camel/camel-private.h
@@ -31,7 +31,7 @@
 #include "config.h"
 #endif
 
-#include <pthread.h>
+#include <glib.h>
 #include <libedataserver/e-msgport.h>
 
 G_BEGIN_DECLS
@@ -153,11 +153,11 @@ struct _CamelVeeFolderPrivate {
 
 
 struct _CamelDataWrapperPrivate {
-	pthread_mutex_t stream_lock;
+	GStaticMutex stream_lock;
 };
 
-#define CAMEL_DATA_WRAPPER_LOCK(dw, l)   (pthread_mutex_lock(&((CamelDataWrapper *)dw)->priv->l))
-#define CAMEL_DATA_WRAPPER_UNLOCK(dw, l) (pthread_mutex_unlock(&((CamelDataWrapper *)dw)->priv->l))
+#define CAMEL_DATA_WRAPPER_LOCK(dw, l)   (g_static_mutex_lock(&((CamelDataWrapper *)dw)->priv->l))
+#define CAMEL_DATA_WRAPPER_UNLOCK(dw, l) (g_static_mutex_unlock(&((CamelDataWrapper *)dw)->priv->l))
 
 
 /* most of this stuff really is private, but the lock can be used by subordinate classes */
