Index: addressbook/backends/file/e-book-backend-file.c
===================================================================
--- addressbook/backends/file/e-book-backend-file.c	(revision 7910)
+++ addressbook/backends/file/e-book-backend-file.c	(working copy)
@@ -43,6 +43,7 @@
 #include "libedataserver/e-dbhash.h"
 #include "libedataserver/e-db3-utils.h"
 #include "libedataserver/e-data-server-util.h"
+#include "libedataserver/e-flag.h"
 
 #include "libebook/e-contact.h"
 
@@ -485,18 +486,15 @@ e_book_backend_file_get_contact_list (EB
 
 typedef struct {
 	EBookBackendFile *bf;
-	GMutex *mutex;
-	GCond *cond;
 	GThread *thread;
-	gboolean stopped;
+	EFlag *running;
 } FileBackendSearchClosure;
 
 static void
 closure_destroy (FileBackendSearchClosure *closure)
 {
 	d(printf ("destroying search closure\n"));
-	g_mutex_free (closure->mutex);
-	g_cond_free (closure->cond);
+	e_flag_free (closure->running);
 	g_free (closure);
 }
 
@@ -506,10 +504,8 @@ init_closure (EDataBookView *book_view, 
 	FileBackendSearchClosure *closure = g_new (FileBackendSearchClosure, 1);
 
 	closure->bf = bf;
-	closure->mutex = g_mutex_new ();
-	closure->cond = g_cond_new ();
 	closure->thread = NULL;
-	closure->stopped = FALSE;
+	closure->running = e_flag_new ();
 
 	g_object_set_data_full (G_OBJECT (book_view), "EBookBackendFile.BookView::closure",
 				closure, (GDestroyNotify)closure_destroy);
@@ -533,7 +529,7 @@ book_view_thread (gpointer data)
 	DB  *db;
 	DBT id_dbt, vcard_dbt;
 	int db_error;
-	gboolean stopped = FALSE, allcontacts;
+	gboolean allcontacts;
 
 	g_return_val_if_fail (E_IS_DATA_BOOK_VIEW (data), NULL);
 
@@ -563,9 +559,7 @@ book_view_thread (gpointer data)
 	}
 
 	d(printf ("signalling parent thread\n"));
-	g_mutex_lock (closure->mutex);
-	g_cond_signal (closure->cond);
-	g_mutex_unlock (closure->mutex);
+	e_flag_set (closure->running);
 
 	if (e_book_backend_summary_is_summary_query (bf->priv->summary, query)) {
 		/* do a summary query */
@@ -574,11 +568,8 @@ book_view_thread (gpointer data)
 
 		for (i = 0; i < ids->len; i ++) {
 			char *id = g_ptr_array_index (ids, i);
-			g_mutex_lock (closure->mutex);
-			stopped = closure->stopped;
-			g_mutex_unlock (closure->mutex);
 
-			if (stopped)
+			if (!e_flag_is_set (closure->running))
 				break;
 
 			string_to_dbt (id, &id_dbt);
@@ -612,11 +603,7 @@ book_view_thread (gpointer data)
 			db_error = dbc->c_get(dbc, &id_dbt, &vcard_dbt, DB_FIRST);
 			while (db_error == 0) {
 
-				g_mutex_lock (closure->mutex);
-				stopped = closure->stopped;
-				g_mutex_unlock (closure->mutex);
-
-				if (stopped)
+				if (!e_flag_is_set (closure->running))
 					break;
 
 				/* don't include the version in the list of cards */
@@ -647,7 +634,7 @@ book_view_thread (gpointer data)
 
 	}
 
-	if (!stopped)
+	if (e_flag_is_set (closure->running))
 		e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
 
 	/* unref the */
@@ -665,15 +652,12 @@ e_book_backend_file_start_book_view (EBo
 {
 	FileBackendSearchClosure *closure = init_closure (book_view, E_BOOK_BACKEND_FILE (backend));
 
-	g_mutex_lock (closure->mutex);
-
 	d(printf ("starting book view thread\n"));
 	closure->thread = g_thread_create (book_view_thread, book_view, TRUE, NULL);
 
-	g_cond_wait (closure->cond, closure->mutex);
+	e_flag_wait (closure->running);
 
 	/* at this point we know the book view thread is actually running */
-	g_mutex_unlock (closure->mutex);
 	d(printf ("returning from start_book_view\n"));
 }
 
@@ -682,14 +666,11 @@ e_book_backend_file_stop_book_view (EBoo
 				    EDataBookView *book_view)
 {
 	FileBackendSearchClosure *closure = get_closure (book_view);
-	gboolean need_join = FALSE;
+	gboolean need_join;
 
 	d(printf ("stopping query\n"));
-	g_mutex_lock (closure->mutex);
-	if (!closure->stopped)
-		need_join = TRUE;
-	closure->stopped = TRUE;
-	g_mutex_unlock (closure->mutex);
+	need_join = e_flag_is_set (closure->running);
+	e_flag_clear (closure->running);
 
 	if (need_join)
 		g_thread_join (closure->thread);
Index: addressbook/backends/groupwise/e-book-backend-groupwise.c
===================================================================
--- addressbook/backends/groupwise/e-book-backend-groupwise.c	(revision 7910)
+++ addressbook/backends/groupwise/e-book-backend-groupwise.c	(working copy)
@@ -40,6 +40,7 @@
 #include "libedataserver/e-sexp.h"
 #include "libedataserver/e-data-server-util.h"
 #include "libedataserver/e-db3-utils.h"
+#include "libedataserver/e-flag.h"
 #include "libedataserver/e-url.h" 
 #include "libebook/e-contact.h"
 #include "libedata-book/e-book-backend-sexp.h"
@@ -2076,17 +2077,14 @@ e_book_backend_groupwise_get_contact_lis
 	
 typedef struct {
 	EBookBackendGroupwise *bg;
-	GMutex *mutex;
-	GCond *cond;
 	GThread *thread;
-	gboolean stopped;
+	EFlag *running;
 } GroupwiseBackendSearchClosure;
 
 static void
 closure_destroy (GroupwiseBackendSearchClosure *closure)
 {
-	g_mutex_free (closure->mutex);
-	g_cond_free (closure->cond);
+	e_flag_free (closure->running);
 	g_free (closure);
 }
 
@@ -2096,10 +2094,8 @@ init_closure (EDataBookView *book_view, 
 	GroupwiseBackendSearchClosure *closure = g_new (GroupwiseBackendSearchClosure, 1);
 
 	closure->bg = bg;
-	closure->mutex = g_mutex_new ();
-	closure->cond = g_cond_new ();
 	closure->thread = NULL;
-	closure->stopped = FALSE;
+	closure->running = e_flag_new ();
 
 	g_object_set_data_full (G_OBJECT (book_view), "EBookBackendGroupwise.BookView::closure",
 				closure, (GDestroyNotify)closure_destroy);
@@ -2121,7 +2117,6 @@ get_contacts_from_cache (EBookBackendGro
 			 GroupwiseBackendSearchClosure *closure)
 {
 	int i;
-	gboolean stopped = FALSE;
 
 	if (enable_debug)
 		printf ("\nread contacts from cache for the ids found in summary\n");
@@ -2129,12 +2124,8 @@ get_contacts_from_cache (EBookBackendGro
 		char *uid;
 		EContact *contact; 
 
-		g_mutex_lock (closure->mutex);
-		stopped = closure->stopped;
-		g_mutex_unlock (closure->mutex);
-
-		if (stopped)
-			break;	
+                if (!e_flag_is_set (closure->running))
+                        break;
 
  		uid = g_ptr_array_index (ids, i);
 		contact = e_book_backend_db_cache_get_contact (ebgw->priv->file_db, uid);
@@ -2143,7 +2134,7 @@ get_contacts_from_cache (EBookBackendGro
 			g_object_unref (contact);
 		}
 	}
-	if (!stopped)
+	if (e_flag_is_set (closure->running))
 		e_data_book_view_notify_complete (book_view, 
 						  GNOME_Evolution_Addressbook_Success);
 }
@@ -2158,7 +2149,6 @@ book_view_thread (gpointer data)
 	const char *query = NULL;
 	EGwFilter *filter = NULL;
 	GPtrArray *ids = NULL;
-	gboolean stopped = FALSE;
 	EDataBookView *book_view = data;
 	GroupwiseBackendSearchClosure *closure = get_closure (book_view);
 	char *view = NULL;
@@ -2173,9 +2163,7 @@ book_view_thread (gpointer data)
 	if (enable_debug)
 		printf ("start book view for %s \n", gwb->priv->book_name);
        	bonobo_object_ref (book_view);
-	g_mutex_lock (closure->mutex);
-	g_cond_signal (closure->cond);
-	g_mutex_unlock (closure->mutex);
+	e_flag_set (closure->running);
 	
 	query = e_data_book_view_get_card_query (book_view);
 	if (enable_debug)
@@ -2207,10 +2195,7 @@ book_view_thread (gpointer data)
 		contacts = e_book_backend_db_cache_get_contacts (gwb->priv->file_db, query);
 		temp_list = contacts;
 		for (; contacts != NULL; contacts = g_list_next(contacts)) {
-			g_mutex_lock (closure->mutex);
-			stopped = closure->stopped;
-			g_mutex_unlock (closure->mutex);
-			if (stopped) {
+			if (!e_flag_is_set (closure->running)) {
 				for (;contacts != NULL; contacts = g_list_next (contacts))
 					g_object_unref (contacts->data);
 				break;
@@ -2218,7 +2203,7 @@ book_view_thread (gpointer data)
 			e_data_book_view_notify_update (book_view, E_CONTACT(contacts->data));
 			g_object_unref (contacts->data);
 		}
-		if (!stopped)
+		if (e_flag_is_set (closure->running))
 			e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
 		if (temp_list)
 			g_list_free (temp_list);
@@ -2346,10 +2331,7 @@ book_view_thread (gpointer data)
 		temp_list = gw_items;
 		for (; gw_items != NULL; gw_items = g_list_next(gw_items)) { 
 
-			g_mutex_lock (closure->mutex);
-			stopped = closure->stopped;
-			g_mutex_unlock (closure->mutex);
-			if (stopped) {
+			if (!e_flag_is_set (closure->running)) {
 				for (;gw_items != NULL; gw_items = g_list_next (gw_items))
 					g_object_unref (gw_items->data);
 				break;
@@ -2370,7 +2352,7 @@ book_view_thread (gpointer data)
 		}
 		if (temp_list)
 			g_list_free (temp_list);
-		if (!stopped)
+		if (e_flag_is_set (closure->running))
 			e_data_book_view_notify_complete (book_view, GNOME_Evolution_Addressbook_Success);
 		if (filter)
 			g_object_unref (filter);
@@ -2399,12 +2381,10 @@ e_book_backend_groupwise_start_book_view
 
 	if (enable_debug)
 		printf ("\ne_book_backend_groupwise_start_book_view...\n");
-	g_mutex_lock (closure->mutex);
 	closure->thread = g_thread_create (book_view_thread, book_view, FALSE, NULL);
-	g_cond_wait (closure->cond, closure->mutex);
+	e_flag_wait (closure->running);
 	
 	/* at this point we know the book view thread is actually running */
-	g_mutex_unlock (closure->mutex);
 }
   
 static void
@@ -2415,10 +2395,7 @@ e_book_backend_groupwise_stop_book_view 
 	
 	if (enable_debug)
 		printf ("\ne_book_backend_groupwise_stop_book_view...\n");
-	g_mutex_lock (closure->mutex);
-	if (!closure->stopped)
-		closure->stopped = TRUE;
-	g_mutex_unlock (closure->mutex);
+	e_flag_clear (closure->running);
 }
 
 static void
@@ -2660,11 +2637,8 @@ build_cache (EBookBackendGroupwise *ebgw
 	if (book_view) {
 		closure = get_closure (book_view);
 		bonobo_object_ref (book_view);
-		if (closure) {
-			g_mutex_lock (closure->mutex);
-			g_cond_signal (closure->cond);
-			g_mutex_unlock (closure->mutex);
-		}
+		if (closure)
+			e_flag_set (closure->running);
 	}
 
 	while (!done) {
@@ -2809,11 +2783,8 @@ update_cache (EBookBackendGroupwise *ebg
 	if (book_view) {
 		closure = get_closure (book_view);
 		bonobo_object_ref (book_view);
-		if (closure) {
-			g_mutex_lock (closure->mutex);
-			g_cond_signal (closure->cond);
-			g_mutex_unlock (closure->mutex);
-		}
+		if (closure)
+			e_flag_set (closure->running);
 	}
 
 	cache_file_name = e_book_backend_db_cache_get_filename(ebgw->priv->file_db);
@@ -2980,11 +2951,8 @@ update_address_book_deltas (EBookBackend
 	if (book_view) {
 		closure = get_closure (book_view);
 		bonobo_object_ref (book_view);
-		if (closure){
-			g_mutex_lock (closure->mutex);
-			g_cond_signal (closure->cond);
-			g_mutex_unlock (closure->mutex);
-		}
+		if (closure)
+			e_flag_set (closure->running);
 	}
 
 	/* update the cache */
Index: addressbook/backends/vcf/e-book-backend-vcf.c
===================================================================
--- addressbook/backends/vcf/e-book-backend-vcf.c	(revision 7910)
+++ addressbook/backends/vcf/e-book-backend-vcf.c	(working copy)
@@ -41,6 +41,7 @@
 #include <glib/gi18n-lib.h>
 
 #include "libedataserver/e-data-server-util.h"
+#include "libedataserver/e-flag.h"
 
 #include "libebook/e-contact.h"
  
@@ -433,18 +434,15 @@ e_book_backend_vcf_get_contact_list (EBo
 typedef struct {
 	EBookBackendVCF *bvcf;
 	EDataBookView *view;
-	GMutex *mutex;
-	GCond *cond;
 	GThread *thread;
-	gboolean stopped;
+	EFlag *running;
 } VCFBackendSearchClosure;
 
 static void
 closure_destroy (VCFBackendSearchClosure *closure)
 {
 	d(printf ("destroying search closure\n"));
-	g_mutex_free (closure->mutex);
-	g_cond_free (closure->cond);
+	e_flag_free (closure->running);
 	g_free (closure);
 }
 
@@ -455,10 +453,8 @@ init_closure (EDataBookView *book_view, 
 
 	closure->bvcf = bvcf;
 	closure->view = book_view;
-	closure->mutex = g_mutex_new ();
-	closure->cond = g_cond_new ();
 	closure->thread = NULL;
-	closure->stopped = FALSE;
+	closure->running = e_flag_new ();
 
 	g_object_set_data_full (G_OBJECT (book_view), "EBookBackendVCF.BookView::closure",
 				closure, (GDestroyNotify)closure_destroy);
@@ -492,9 +488,7 @@ book_view_thread (gpointer data)
 		e_data_book_view_notify_status_message (book_view, _("Searching..."));
 
 	d(printf ("signalling parent thread\n"));
-	g_mutex_lock (closure->mutex);
-	g_cond_signal (closure->cond);
-	g_mutex_unlock (closure->mutex);
+	e_flag_set (closure->running);
 
 	for (l = closure->bvcf->priv->contact_list; l; l = l->next) {
 		char *vcard_string = l->data;
@@ -502,11 +496,11 @@ book_view_thread (gpointer data)
 		e_data_book_view_notify_update (closure->view, contact);
 		g_object_unref (contact);
 
-		if (closure->stopped)
+		if (!e_flag_is_set (closure->running))
 			break;
 	}
 
-	if (!closure->stopped)
+	if (e_flag_is_set (closure->running))
 		e_data_book_view_notify_complete (closure->view, GNOME_Evolution_Addressbook_Success);
 
 	/* unref the book view */
@@ -524,15 +518,12 @@ e_book_backend_vcf_start_book_view (EBoo
 {
 	VCFBackendSearchClosure *closure = init_closure (book_view, E_BOOK_BACKEND_VCF (backend));
 
-	g_mutex_lock (closure->mutex);
-
 	d(printf ("starting book view thread\n"));
 	closure->thread = g_thread_create (book_view_thread, book_view, TRUE, NULL);
 
-	g_cond_wait (closure->cond, closure->mutex);
+	e_flag_wait (closure->running);
 
 	/* at this point we know the book view thread is actually running */
-	g_mutex_unlock (closure->mutex);
 	d(printf ("returning from start_book_view\n"));
 
 }
@@ -542,14 +533,11 @@ e_book_backend_vcf_stop_book_view (EBook
 				   EDataBookView *book_view)
 {
 	VCFBackendSearchClosure *closure = get_closure (book_view);
-	gboolean need_join = FALSE;
+	gboolean need_join;
 
 	d(printf ("stopping query\n"));
-	g_mutex_lock (closure->mutex);
-	if (!closure->stopped)
-		need_join = TRUE;
-	closure->stopped = TRUE;
-	g_mutex_unlock (closure->mutex);
+	need_join = e_flag_is_set (closure->running);
+	e_flag_clear (closure->running);
 
 	if (need_join)
 		g_thread_join (closure->thread);
Index: calendar/libecal/e-cal.c
===================================================================
--- calendar/libecal/e-cal.c	(revision 7910)
+++ calendar/libecal/e-cal.c	(working copy)
@@ -33,6 +33,7 @@
 #include <bonobo/bonobo-main.h>
 
 #include "libedataserver/e-component-listener.h"
+#include "libedataserver/e-flag.h"
 #include "libedataserver/e-url.h"
 #include "e-cal-marshal.h"
 #include "e-cal-time-util.h"
@@ -50,8 +51,7 @@ get_read_only (ECal *ecal, gboolean *rea
 
 
 typedef struct {
-	GMutex *mutex;
-	GCond *cond;
+	EFlag *done;
 	ECalendarStatus status;
 
 	char *uid;
@@ -304,8 +304,7 @@ e_calendar_new_op (ECal *ecal)
 {
 	ECalendarOp *op = g_new0 (ECalendarOp, 1);
 
-	op->mutex = g_mutex_new ();
-	op->cond = g_cond_new ();
+	op->done = e_flag_new ();
 
 	ecal->priv->current_op = op;
 
@@ -327,8 +326,7 @@ static void
 e_calendar_free_op (ECalendarOp *op)
 {
 	/* XXX more stuff here */
-	g_cond_free (op->cond);
-	g_mutex_free (op->mutex);
+	e_flag_free (op->done);
 	g_free (op);
 }
 
@@ -446,14 +444,10 @@ cal_read_only_cb (ECalListener *listener
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->bool = read_only;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -475,14 +469,10 @@ cal_cal_address_cb (ECalListener *listen
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (address);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -498,14 +488,10 @@ cal_alarm_address_cb (ECalListener *list
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (address);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -521,14 +507,10 @@ cal_ldap_attribute_cb (ECalListener *lis
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (attribute);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -544,14 +526,10 @@ cal_static_capabilities_cb (ECalListener
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (capabilities);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -567,13 +545,9 @@ cal_opened_cb (ECalListener *listener, E
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -589,13 +563,9 @@ cal_removed_cb (ECalListener *listener, 
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -611,14 +581,10 @@ cal_object_created_cb (ECalListener *lis
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->uid = g_strdup (uid);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -634,13 +600,9 @@ cal_object_modified_cb (ECalListener *li
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -656,13 +618,9 @@ cal_object_removed_cb (ECalListener *lis
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -678,13 +636,9 @@ cal_alarm_discarded_cb (ECalListener *li
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -700,13 +654,9 @@ cal_objects_received_cb (ECalListener *l
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -723,8 +673,6 @@ cal_objects_sent_cb (ECalListener *liste
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (users);
 	op->string = g_strdup (object);
@@ -732,9 +680,7 @@ cal_objects_sent_cb (ECalListener *liste
 	for (l = op->list; l; l = l->next)
 		l->data = g_strdup (l->data);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -750,14 +696,10 @@ cal_default_object_requested_cb (ECalLis
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (object);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -773,14 +715,10 @@ cal_object_requested_cb (ECalListener *l
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (object);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -797,17 +735,13 @@ cal_object_list_cb (ECalListener *listen
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (objects);
 	
 	for (l = op->list; l; l = l->next)
 		l->data = icalcomponent_new_clone (l->data);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -823,14 +757,10 @@ cal_attachment_list_cb (ECalListener *li
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->slist = g_slist_copy (attachments);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -846,15 +776,10 @@ cal_get_timezone_cb (ECalListener *liste
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->string = g_strdup (object);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
-
+	e_flag_set (op->done);
 }
 
 static void
@@ -870,15 +795,10 @@ cal_add_timezone_cb (ECalListener *liste
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->uid = g_strdup (tzid);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
-
+	e_flag_set (op->done);
 }
 
 static void
@@ -894,13 +814,9 @@ cal_set_default_timezone_cb (ECalListene
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -917,8 +833,6 @@ cal_get_changes_cb (ECalListener *listen
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (changes);
 
@@ -932,9 +846,7 @@ cal_get_changes_cb (ECalListener *listen
 		l->data = new_ccc;
 	}
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -951,17 +863,13 @@ cal_get_free_busy_cb (ECalListener *list
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->list = g_list_copy (freebusy);
 
 	for (l = op->list; l; l = l->next)
 		l->data = e_cal_component_clone (l->data);
 
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);
+	e_flag_set (op->done);
 }
 
 static void
@@ -977,14 +885,10 @@ cal_query_cb (ECalListener *listener, EC
 		return;
 	}
 
-	g_mutex_lock (op->mutex);
-
 	op->status = status;
 	op->query = e_cal_view_new (query, op->listener, ecal);
 	
-	g_cond_signal (op->cond);
-
-	g_mutex_unlock (op->mutex);	
+	e_flag_set (op->done);
 }
 
 static gboolean  
@@ -1724,7 +1628,6 @@ open_calendar (ECal *ecal, gboolean only
 	}
 	/* start the open operation */
 	our_op = e_calendar_new_op (ecal);
-	g_mutex_lock (our_op->mutex);
 
 	g_mutex_unlock (priv->mutex);
 
@@ -1737,7 +1640,6 @@ open_calendar (ECal *ecal, gboolean only
 
 		if (priv->auth_func == NULL) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 			priv->load_state = E_CAL_LOAD_NOT_LOADED;
 			*status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED;
@@ -1747,7 +1649,6 @@ open_calendar (ECal *ecal, gboolean only
 		username = e_source_get_duped_property (priv->source, "username");
 		if (!username) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 			priv->load_state = E_CAL_LOAD_NOT_LOADED;
 			*status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED;
@@ -1777,7 +1678,6 @@ open_calendar (ECal *ecal, gboolean only
 
 		if (!key) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 			priv->load_state = E_CAL_LOAD_NOT_LOADED;
 			*status = E_CALENDAR_STATUS_URI_NOT_LOADED;
@@ -1788,7 +1688,6 @@ open_calendar (ECal *ecal, gboolean only
 
 		if (!password) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 			priv->load_state = E_CAL_LOAD_NOT_LOADED;
 			*status = E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED; 
@@ -1813,7 +1712,6 @@ open_calendar (ECal *ecal, gboolean only
 
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 		
 		CORBA_exception_free (&ev);
@@ -1827,14 +1725,11 @@ open_calendar (ECal *ecal, gboolean only
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	*status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 	if (*status == E_CALENDAR_STATUS_OK) {
 		priv->load_state = E_CAL_LOAD_LOADED;
@@ -1990,8 +1885,6 @@ e_cal_remove (ECal *ecal, GError **error
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2000,7 +1893,6 @@ e_cal_remove (ECal *ecal, GError **error
 	GNOME_Evolution_Calendar_Cal_remove (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2012,14 +1904,11 @@ e_cal_remove (ECal *ecal, GError **error
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2251,8 +2140,6 @@ get_read_only (ECal *ecal, gboolean *rea
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	/* set it to true so that op does not emit cond signals for all notifications
 	   from the backend */
 	our_op->bool = TRUE;
@@ -2265,7 +2152,6 @@ get_read_only (ECal *ecal, gboolean *rea
 	GNOME_Evolution_Calendar_Cal_isReadOnly (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2277,9 +2163,7 @@ get_read_only (ECal *ecal, gboolean *rea
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
@@ -2287,7 +2171,6 @@ get_read_only (ECal *ecal, gboolean *rea
 		*read_only = our_op->bool;
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 	E_CALENDAR_CHECK_STATUS (status, error);
 }
@@ -2330,8 +2213,6 @@ e_cal_get_cal_address (ECal *ecal, char 
 
 		our_op = e_calendar_new_op (ecal);
 
-		g_mutex_lock (our_op->mutex);
-
 		g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2340,7 +2221,6 @@ e_cal_get_cal_address (ECal *ecal, char 
 		GNOME_Evolution_Calendar_Cal_getCalAddress (priv->cal, &ev);
 		if (BONOBO_EX (&ev)) {
 			e_calendar_remove_op (ecal, our_op);
-			g_mutex_unlock (our_op->mutex);
 			e_calendar_free_op (our_op);
 
 			CORBA_exception_free (&ev);
@@ -2352,14 +2232,11 @@ e_cal_get_cal_address (ECal *ecal, char 
 
 		CORBA_exception_free (&ev);
 
-		/* wait for something to happen (both cancellation and a
-		   successful response will notity us via our cv */
-		g_cond_wait (our_op->cond, our_op->mutex);
+		e_flag_wait (our_op->done);
 
 		status = our_op->status;
 		*cal_address = our_op->string;
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (status, error);
@@ -2407,8 +2284,6 @@ e_cal_get_alarm_email_address (ECal *eca
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2417,7 +2292,6 @@ e_cal_get_alarm_email_address (ECal *eca
 	GNOME_Evolution_Calendar_Cal_getAlarmEmailAddress (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2429,15 +2303,12 @@ e_cal_get_alarm_email_address (ECal *eca
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*alarm_address = our_op->string;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2480,8 +2351,6 @@ e_cal_get_ldap_attribute (ECal *ecal, ch
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2490,7 +2359,6 @@ e_cal_get_ldap_attribute (ECal *ecal, ch
 	GNOME_Evolution_Calendar_Cal_getLdapAttribute (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2502,15 +2370,12 @@ e_cal_get_ldap_attribute (ECal *ecal, ch
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*ldap_attribute = our_op->string;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2543,8 +2408,6 @@ load_static_capabilities (ECal *ecal, GE
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -2553,7 +2416,6 @@ load_static_capabilities (ECal *ecal, GE
 	GNOME_Evolution_Calendar_Cal_getStaticCapabilities (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2565,15 +2427,12 @@ load_static_capabilities (ECal *ecal, GE
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	priv->capabilities = our_op->string;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2782,8 +2641,6 @@ e_cal_get_default_object (ECal *ecal, ic
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -2791,7 +2648,6 @@ e_cal_get_default_object (ECal *ecal, ic
 	GNOME_Evolution_Calendar_Cal_getDefaultObject (priv->cal, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2803,9 +2659,7 @@ e_cal_get_default_object (ECal *ecal, ic
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK) {
@@ -2818,7 +2672,6 @@ e_cal_get_default_object (ECal *ecal, ic
 	g_free (our_op->string);
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2863,15 +2716,12 @@ e_cal_get_attachments_for_comp (ECal *ec
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
 	GNOME_Evolution_Calendar_Cal_getAttachmentList (priv->cal, uid, rid ? rid : "", &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2883,9 +2733,7 @@ e_cal_get_attachments_for_comp (ECal *ec
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK){ 
@@ -2895,7 +2743,6 @@ e_cal_get_attachments_for_comp (ECal *ec
 	}
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -2940,8 +2787,6 @@ e_cal_get_object (ECal *ecal, const char
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -2949,7 +2794,6 @@ e_cal_get_object (ECal *ecal, const char
 	GNOME_Evolution_Calendar_Cal_getObject (priv->cal, uid, rid ? rid : "", &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -2961,9 +2805,7 @@ e_cal_get_object (ECal *ecal, const char
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK){ 
@@ -3011,7 +2853,6 @@ e_cal_get_object (ECal *ecal, const char
 	g_free (our_op->string);
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -3057,8 +2898,6 @@ e_cal_get_objects_for_uid (ECal *ecal, c
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -3066,7 +2905,6 @@ e_cal_get_objects_for_uid (ECal *ecal, c
 	GNOME_Evolution_Calendar_Cal_getObject (priv->cal, uid, "", &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -3078,9 +2916,7 @@ e_cal_get_objects_for_uid (ECal *ecal, c
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK){ 
@@ -3138,7 +2974,6 @@ e_cal_get_objects_for_uid (ECal *ecal, c
 	g_free (our_op->string);
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -3208,8 +3043,6 @@ e_cal_get_changes (ECal *ecal, const cha
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -3218,7 +3051,6 @@ e_cal_get_changes (ECal *ecal, const cha
 
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -3230,15 +3062,12 @@ e_cal_get_changes (ECal *ecal, const cha
 	
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*changes = our_op->list;
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -3308,8 +3137,6 @@ e_cal_get_object_list (ECal *ecal, const
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -3318,7 +3145,6 @@ e_cal_get_object_list (ECal *ecal, const
 
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -3330,15 +3156,12 @@ e_cal_get_object_list (ECal *ecal, const
 	
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*objects = our_op->list;
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -3441,8 +3264,6 @@ e_cal_get_free_busy (ECal *ecal, GList *
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	/* create the CORBA user list to be passed to the backend */
@@ -3462,7 +3283,6 @@ e_cal_get_free_busy (ECal *ecal, GList *
 	
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -3474,15 +3294,12 @@ e_cal_get_free_busy (ECal *ecal, GList *
 	
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*freebusy = our_op->list;
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4176,8 +3993,6 @@ e_cal_discard_alarm (ECal *ecal, ECalCom
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	e_cal_component_get_uid (comp, &uid);
@@ -4187,7 +4002,6 @@ e_cal_discard_alarm (ECal *ecal, ECalCom
 	GNOME_Evolution_Calendar_Cal_discardAlarm (priv->cal, uid, auid, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4199,14 +4013,11 @@ e_cal_discard_alarm (ECal *ecal, ECalCom
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4422,8 +4233,6 @@ e_cal_create_object (ECal *ecal, icalcom
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4431,7 +4240,6 @@ e_cal_create_object (ECal *ecal, icalcom
 	GNOME_Evolution_Calendar_Cal_createObject (priv->cal, icalcomponent_as_ical_string (icalcomp), &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4443,9 +4251,7 @@ e_cal_create_object (ECal *ecal, icalcom
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+        e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	if (uid)
@@ -4455,7 +4261,6 @@ e_cal_create_object (ECal *ecal, icalcom
 	}
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4505,8 +4310,6 @@ e_cal_modify_object (ECal *ecal, icalcom
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4514,7 +4317,6 @@ e_cal_modify_object (ECal *ecal, icalcom
 	GNOME_Evolution_Calendar_Cal_modifyObject (priv->cal, icalcomponent_as_ical_string (icalcomp), mod, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4526,14 +4328,11 @@ e_cal_modify_object (ECal *ecal, icalcom
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4586,8 +4385,6 @@ e_cal_remove_object_with_mod (ECal *ecal
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 
@@ -4596,7 +4393,6 @@ e_cal_remove_object_with_mod (ECal *ecal
 	GNOME_Evolution_Calendar_Cal_removeObject (priv->cal, uid, rid ? rid : "", mod, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4608,14 +4404,11 @@ e_cal_remove_object_with_mod (ECal *ecal
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4680,8 +4473,6 @@ e_cal_receive_objects (ECal *ecal, icalc
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4689,7 +4480,6 @@ e_cal_receive_objects (ECal *ecal, icalc
 	GNOME_Evolution_Calendar_Cal_receiveObjects (priv->cal, icalcomponent_as_ical_string (icalcomp), &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4701,14 +4491,11 @@ e_cal_receive_objects (ECal *ecal, icalc
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4754,8 +4541,6 @@ e_cal_send_objects (ECal *ecal, icalcomp
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -4763,7 +4548,6 @@ e_cal_send_objects (ECal *ecal, icalcomp
 	GNOME_Evolution_Calendar_Cal_sendObjects (priv->cal, icalcomponent_as_ical_string (icalcomp), &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4775,9 +4559,7 @@ e_cal_send_objects (ECal *ecal, icalcomp
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*users = our_op->list;
@@ -4798,7 +4580,6 @@ e_cal_send_objects (ECal *ecal, icalcomp
 	g_free (our_op->string);
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4843,8 +4624,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (priv->mutex);
 
 	/* Check for well known zones and in the cache */
@@ -4853,7 +4632,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	/* If tzid is NULL or "" we return NULL, since it is a 'local time'. */
 	if (!tzid || !tzid[0]) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		*zone = NULL;
@@ -4871,7 +4649,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	
 	if (*zone) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error);	
@@ -4883,7 +4660,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	GNOME_Evolution_Calendar_Cal_getTimezone (priv->cal, tzid, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -4895,9 +4671,7 @@ e_cal_get_timezone (ECal *ecal, const ch
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
         if (status != E_CALENDAR_STATUS_OK){ 
@@ -4911,7 +4685,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	
 	if (!icalcomp) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (status, error);
@@ -4922,7 +4695,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 		icaltimezone_free (*zone, 1);
 
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OBJECT_NOT_FOUND, error);
@@ -4932,7 +4704,6 @@ e_cal_get_timezone (ECal *ecal, const ch
 	g_hash_table_insert (priv->timezones, icaltimezone_get_tzid (*zone), *zone);
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -4977,15 +4748,12 @@ e_cal_add_timezone (ECal *ecal, icaltime
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (priv->mutex);
 
 	/* Make sure we have a valid component - UTC doesn't, nor do
 	 * we really have to add it */
 	if (izone == icaltimezone_get_utc_timezone ()) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 		
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_OK, error);
@@ -4994,7 +4762,6 @@ e_cal_add_timezone (ECal *ecal, icaltime
 	icalcomp = icaltimezone_get_component (izone);
 	if (!icalcomp) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
@@ -5009,7 +4776,6 @@ e_cal_add_timezone (ECal *ecal, icaltime
 	GNOME_Evolution_Calendar_Cal_addTimezone (priv->cal, tzobj, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -5021,14 +4787,11 @@ e_cal_add_timezone (ECal *ecal, icaltime
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -5070,8 +4833,6 @@ e_cal_get_query (ECal *ecal, const char 
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (ecal->priv->mutex);
 
 	CORBA_exception_init (&ev);
@@ -5081,7 +4842,6 @@ e_cal_get_query (ECal *ecal, const char 
 
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -5093,9 +4853,7 @@ e_cal_get_query (ECal *ecal, const char 
 	
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 	*query = our_op->query;
@@ -5103,7 +4861,6 @@ e_cal_get_query (ECal *ecal, const char 
 	bonobo_object_unref (BONOBO_OBJECT (our_op->listener));
 	
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
@@ -5148,15 +4905,12 @@ e_cal_set_default_timezone (ECal *ecal, 
 
 	our_op = e_calendar_new_op (ecal);
 
-	g_mutex_lock (our_op->mutex);
-
 	g_mutex_unlock (priv->mutex);
 
 	/* FIXME Adding it to the server to change the tzid */
 	icalcomp = icaltimezone_get_component (zone);
 	if (!icalcomp) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_INVALID_ARG, error);
@@ -5171,7 +4925,6 @@ e_cal_set_default_timezone (ECal *ecal, 
 	GNOME_Evolution_Calendar_Cal_setDefaultTimezone (priv->cal, tzobj, &ev);
 	if (BONOBO_EX (&ev)) {
 		e_calendar_remove_op (ecal, our_op);
-		g_mutex_unlock (our_op->mutex);
 		e_calendar_free_op (our_op);
 
 		CORBA_exception_free (&ev);
@@ -5183,9 +4936,7 @@ e_cal_set_default_timezone (ECal *ecal, 
 
 	CORBA_exception_free (&ev);
 
-	/* wait for something to happen (both cancellation and a
-	   successful response will notity us via our cv */
-	g_cond_wait (our_op->cond, our_op->mutex);
+	e_flag_wait (our_op->done);
 
 	status = our_op->status;
 
@@ -5197,7 +4948,6 @@ e_cal_set_default_timezone (ECal *ecal, 
 	}
 
 	e_calendar_remove_op (ecal, our_op);
-	g_mutex_unlock (our_op->mutex);
 	e_calendar_free_op (our_op);
 
 	E_CALENDAR_CHECK_STATUS (status, error);
