Index: evolution-data-server-2.28.2/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
===================================================================
--- evolution-data-server-2.28.2.orig/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
+++ evolution-data-server-2.28.2/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
@@ -825,9 +825,15 @@ e_gw_item_new_from_cal_component (const
 
 	g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
 
+	e_cal_backend_groupwise_priv_lock (cbgw);
+	
 	item = e_gw_item_new_empty ();
 	e_gw_item_set_container_id (item, container);
-	return set_properties_from_cal_component (item, comp, cbgw);
+	item = set_properties_from_cal_component (item, comp, cbgw);
+
+	e_cal_backend_groupwise_priv_unlock (cbgw);
+
+	return item;
 }
 
 /* Set the attendee list and send options to EGwItem */
@@ -844,8 +850,10 @@ e_gw_item_new_for_delegate_from_cal (ECa
 	e_gw_item_set_id (item, e_cal_component_get_gw_id (comp));
 	user_email = e_gw_connection_get_user_email (e_cal_backend_groupwise_get_connection (cbgw));
 
+	e_cal_backend_groupwise_priv_lock (cbgw);
 	set_attendees_to_item (item, comp, default_zone, TRUE, user_email);
 	add_send_options_data_to_item (item, comp, default_zone);
+	e_cal_backend_groupwise_priv_unlock (cbgw);
 
 	return item;
 }
@@ -1012,13 +1020,41 @@ get_cn_from_display_name (gchar *display
 	}
 }
 
+static void
+sanitize_component (ECalComponent *comp, const gchar *server_uid, const char *container_id)
+{
+	icalproperty *icalprop;
+	gint i;
+	GString *str = g_string_new ("");;
+
+	if (server_uid) {
+
+		/* the ID returned by sendItemResponse includes the container ID of the
+		   inbox folder, so we need to replace that with our container ID */
+		for (i = 0; i < strlen (server_uid); i++) {
+			str = g_string_append_c (str, server_uid[i]);
+			if (server_uid[i] == ':') {
+				str = g_string_append (str, container_id);
+				break;
+			}
+		}
+
+		/* add the extra property to the component */
+		icalprop = icalproperty_new_x (str->str);
+		icalproperty_set_x_name (icalprop, "X-GWRECORDID");
+		icalcomponent_add_property (e_cal_component_get_icalcomponent (comp), icalprop);
+
+	}
+	g_string_free (str, TRUE);
+}
+
 ECalComponent *
 e_gw_item_to_cal_component (EGwItem *item, ECalBackendGroupwise *cbgw)
 {
 	ECalComponent *comp;
 	ECalComponentText text;
 	ECalComponentDateTime dt;
-	const gchar *description, *uid;
+	const gchar *description, *uid, *item_id;
 	const gchar *t;
 	gchar *name;
 	GList *category_ids;
@@ -1035,11 +1071,13 @@ e_gw_item_to_cal_component (EGwItem *ite
 	EGwItemOrganizer *organizer;
 	EGwItemType item_type;
 
+	g_return_val_if_fail (E_IS_GW_ITEM (item), NULL);
+	
+	e_cal_backend_groupwise_priv_lock (cbgw);
+	
 	default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
 	categories_by_id = e_cal_backend_groupwise_get_categories_by_id (cbgw);
 
-	g_return_val_if_fail (E_IS_GW_ITEM (item), NULL);
-
 	comp = e_cal_component_new ();
 
 	item_type = e_gw_item_get_item_type (item);
@@ -1052,18 +1090,16 @@ e_gw_item_to_cal_component (EGwItem *ite
 		e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_JOURNAL);
 	else {
 		g_object_unref (comp);
+		e_cal_backend_groupwise_priv_unlock (cbgw);
 		return NULL;
 	}
 
 	/* set common properties */
 	/* GW server ID */
-	description = e_gw_item_get_id (item);
-	if (description) {
-		icalproperty *icalprop;
-
-		icalprop = icalproperty_new_x (description);
-		icalproperty_set_x_name (icalprop, "X-GWRECORDID");
-		icalcomponent_add_property (e_cal_component_get_icalcomponent (comp), icalprop);
+	item_id = e_gw_item_get_id (item);
+	if (item_id) {
+		const gchar *container_id = e_cal_backend_groupwise_get_container_id (cbgw);
+		sanitize_component (comp, item_id, container_id);
 	}
 
 	if (e_gw_item_get_reply_request (item)) {
@@ -1175,8 +1211,10 @@ e_gw_item_to_cal_component (EGwItem *ite
 		}
 
 		e_cal_component_set_dtstart (comp, &dt);
-	} else
+	} else {
+		e_cal_backend_groupwise_priv_unlock (cbgw);
 		return NULL;
+	}
 
 	/* UID */
 	if (e_gw_item_get_recurrence_key (item) != 0) {
@@ -1197,9 +1235,10 @@ e_gw_item_to_cal_component (EGwItem *ite
 
 		uid = e_gw_item_get_icalid (item);
 		if (uid)
-			e_cal_component_set_uid (comp, e_gw_item_get_icalid (item));
+			e_cal_component_set_uid (comp, uid);
 		else {
 			g_object_unref (comp);
+			e_cal_backend_groupwise_priv_unlock (cbgw);
 			return NULL;
 		}
 	}
@@ -1405,10 +1444,12 @@ e_gw_item_to_cal_component (EGwItem *ite
 	case E_GW_ITEM_TYPE_NOTE:
 		break;
 	default :
+		e_cal_backend_groupwise_priv_unlock (cbgw);
 		return NULL;
 	}
 
 	e_cal_component_commit_sequence (comp);
+	e_cal_backend_groupwise_priv_unlock (cbgw);
 
 	return comp;
 }
@@ -1726,17 +1767,22 @@ close_freebusy_session (EGwConnection *c
 }
 
 EGwConnectionStatus
-e_gw_connection_get_freebusy_info (EGwConnection *cnc, GList *users, time_t start, time_t end, GList **freebusy, icaltimezone *default_zone)
+e_gw_connection_get_freebusy_info (ECalBackendGroupwise *cbgw, GList *users, time_t start, time_t end, GList **freebusy)
 {
         SoupSoapMessage *msg;
         SoupSoapResponse *response;
         EGwConnectionStatus status;
         SoupSoapParameter *param, *subparam, *param_outstanding;
+	EGwConnection *cnc;
         gchar *session;
 	gchar *outstanding = NULL;
 	gboolean resend_request = TRUE;
 	gint request_iteration = 0;
+	icaltimezone *default_zone;
 
+	default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
+	cnc = e_cal_backend_groupwise_get_connection (cbgw);
+	
 	g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_CONNECTION);
 
 	/* Perform startFreeBusySession */
@@ -1815,6 +1861,8 @@ e_gw_connection_get_freebusy_info (EGwCo
 		GSList *attendee_list = NULL;
 		icalcomponent *icalcomp = NULL;
 		icaltimetype start_time, end_time;
+	
+		e_cal_backend_groupwise_priv_lock (cbgw);
 
 		tmp = soup_soap_parameter_get_first_child_by_name (subparam, "email");
 		if (tmp)
@@ -1861,6 +1909,7 @@ e_gw_connection_get_freebusy_info (EGwCo
 		if (!param_blocks) {
 			g_object_unref (response);
 			g_object_unref (msg);
+			e_cal_backend_groupwise_priv_unlock (cbgw);
 			return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
 		}
 
@@ -1932,6 +1981,7 @@ e_gw_connection_get_freebusy_info (EGwCo
 		e_cal_component_commit_sequence (comp);
 		*freebusy = g_list_append (*freebusy, e_cal_component_get_as_string (comp));
 		g_object_unref (comp);
+		e_cal_backend_groupwise_priv_unlock (cbgw);
 	}
 
         g_object_unref (msg);
Index: evolution-data-server-2.28.2/calendar/backends/groupwise/e-cal-backend-groupwise-utils.h
===================================================================
--- evolution-data-server-2.28.2.orig/calendar/backends/groupwise/e-cal-backend-groupwise-utils.h
+++ evolution-data-server-2.28.2/calendar/backends/groupwise/e-cal-backend-groupwise-utils.h
@@ -52,7 +52,7 @@ void          e_gw_item_set_changes (EGw
  */
 EGwConnectionStatus e_gw_connection_create_appointment (EGwConnection *cnc, const gchar *container, ECalBackendGroupwise *cbgw, ECalComponent *comp, GSList **id_list);
 EGwConnectionStatus e_gw_connection_send_appointment (ECalBackendGroupwise *cbgw, const gchar *container, ECalComponent *comp, icalproperty_method method, gboolean all_instances, ECalComponent **created_comp, icalparameter_partstat *pstatus);
-EGwConnectionStatus e_gw_connection_get_freebusy_info (EGwConnection *cnc, GList *users, time_t start, time_t end, GList **freebusy, icaltimezone *default_zone);
+EGwConnectionStatus e_gw_connection_get_freebusy_info (ECalBackendGroupwise *cbgw, GList *users, time_t start, time_t end, GList **freebusy);
 gboolean e_cal_backend_groupwise_store_settings (GwSettings *hold);
 gboolean e_cal_backend_groupwise_utils_check_delegate (ECalComponent *comp, const gchar *email);
 
Index: evolution-data-server-2.28.2/calendar/backends/groupwise/e-cal-backend-groupwise.c
===================================================================
--- evolution-data-server-2.28.2.orig/calendar/backends/groupwise/e-cal-backend-groupwise.c
+++ evolution-data-server-2.28.2/calendar/backends/groupwise/e-cal-backend-groupwise.c
@@ -69,8 +69,6 @@ typedef struct {
 
 /* Private part of the CalBackendGroupwise structure */
 struct _ECalBackendGroupwisePrivate {
-	/* A mutex to control access to the private structure */
-	GMutex *mutex;
 	EGwConnection *cnc;
 	ECalBackendStore *store;
 	gboolean read_only;
@@ -80,7 +78,6 @@ struct _ECalBackendGroupwisePrivate {
 	gchar *container_id;
 	CalMode mode;
 	gboolean mode_changed;
-	icaltimezone *default_zone;
 	GHashTable *categories_by_id;
 	GHashTable *categories_by_name;
 
@@ -94,14 +91,19 @@ struct _ECalBackendGroupwisePrivate {
 	gchar *user_email;
 	gchar *local_attachments_store;
 
+	/* A mutex to control access to the private structure for the following */
+	GStaticRecMutex rec_mutex;
+	icaltimezone *default_zone;
 	guint timeout_id;
 	GThread *dthread;
 	SyncDelta *dlock;
 };
 
+#define PRIV_LOCK(p)   (g_static_rec_mutex_lock (&(p)->rec_mutex))
+#define PRIV_UNLOCK(p) (g_static_rec_mutex_unlock (&(p)->rec_mutex))
+
 static void e_cal_backend_groupwise_dispose (GObject *object);
 static void e_cal_backend_groupwise_finalize (GObject *object);
-static void sanitize_component (ECalBackendSync *backend, ECalComponent *comp, gchar *server_uid);
 static ECalBackendSyncStatus
 e_cal_backend_groupwise_add_timezone (ECalBackendSync *backend, EDataCal *cal, const gchar *tzobj);
 static const gchar * get_gw_item_id (icalcomponent *icalcomp);
@@ -150,7 +152,23 @@ e_cal_backend_groupwise_get_default_zone
 	return cbgw->priv->default_zone;
 }
 
-static GMutex *mutex = NULL;
+const char *
+e_cal_backend_groupwise_get_container_id (ECalBackendGroupwise *cbgw) 
+{
+	return cbgw->priv->container_id;
+}
+
+void
+e_cal_backend_groupwise_priv_lock (ECalBackendGroupwise *cbgw)
+{
+       PRIV_LOCK (cbgw->priv);
+}
+
+void
+e_cal_backend_groupwise_priv_unlock (ECalBackendGroupwise *cbgw)
+{
+       PRIV_UNLOCK (cbgw->priv);
+}
 
 static const gchar *
 get_element_type (icalcomponent_kind kind)
@@ -195,11 +213,6 @@ populate_cache (ECalBackendGroupwise *cb
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
 	total = priv->total_count;
 
-	if (!mutex) {
-		mutex = g_mutex_new ();
-	}
-
-	g_mutex_lock (mutex);
 
 	type = get_element_type (kind);
 
@@ -237,7 +250,6 @@ populate_cache (ECalBackendGroupwise *cb
 				"recipients message recipientStatus attachments default peek", filter[i], &cursor);
 		if (status != E_GW_CONNECTION_STATUS_OK) {
 			e_cal_backend_groupwise_notify_error_code (cbgw, status);
-			g_mutex_unlock (mutex);
 			return status;
 		}
 		done = FALSE;
@@ -257,7 +269,6 @@ populate_cache (ECalBackendGroupwise *cb
 			status = e_gw_connection_read_cursor (priv->cnc, priv->container_id, cursor, forward, CURSOR_ITEM_LIMIT, position, &list);
 			if (status != E_GW_CONNECTION_STATUS_OK) {
 				e_cal_backend_groupwise_notify_error_code (cbgw, status);
-				g_mutex_unlock (mutex);
 				return status;
 			}
 			for (l = list; l != NULL; l = g_list_next(l)) {
@@ -305,30 +316,45 @@ populate_cache (ECalBackendGroupwise *cb
 	}
 	e_cal_backend_notify_view_progress (E_CAL_BACKEND (cbgw), "", 100);
 
-	g_mutex_unlock (mutex);
 	return E_GW_CONNECTION_STATUS_OK;
 }
 
+typedef struct
+{
+	EGwItemCalId *calid;
+	ECalBackendStore *store;	
+} CompareIdData;
+
 static gint
 compare_ids (gconstpointer a, gconstpointer b)
 {
 	ECalComponentId *cache_id = (ECalComponentId *) a;
-	ECalComponentId *server_id = (ECalComponentId *) b;
-
-	if (g_str_equal (cache_id->uid, server_id->uid)) {
-		if (cache_id->rid && server_id->rid) {
-			if (g_str_equal (cache_id->rid, server_id->rid))
-				return 0;
-			else
-				return 1;
-		} else if (!cache_id->rid && !server_id->rid)
-			return 0;
+	CompareIdData *data = (CompareIdData *) b;
+	EGwItemCalId *calid = data->calid;
+	ECalBackendStore *store = data->store;
+	
+	if (!calid->recur_key)
+		return g_strcmp0 (cache_id->uid, calid->ical_id);
+	else {
+		ECalComponent *comp;
+		gint ret = 1;
+		const char *cache_item_id;
+	       
+		if (strcmp (cache_id->uid, calid->recur_key))
+			return 1;
+
+		comp = e_cal_backend_store_get_component (store, cache_id->uid, cache_id->rid);
+		cache_item_id = e_cal_component_get_gw_id (comp);
+		if (!strcmp (cache_item_id, calid->item_id))
+			ret = 0;
 
-		return 1;
-	} else
-		return 1;
+		g_object_unref (comp);
+		return ret;
+	}
 }
 
+#define ATTEMPTS_KEY "attempts"
+
 static gboolean
 get_deltas (gpointer handle)
 {
@@ -343,10 +369,8 @@ get_deltas (gpointer handle)
 	GPtrArray *uid_array = NULL;
 	gchar *time_string = NULL;
 	gchar t_str [26];
+	gchar *attempts;
 	const gchar *serv_time;
-	static GStaticMutex connecting = G_STATIC_MUTEX_INIT;
-	const gchar *key = "attempts";
-	const gchar *attempts;
 	const gchar *position;
 
 	EGwFilter *filter;
@@ -360,19 +384,19 @@ get_deltas (gpointer handle)
 
 	if (!handle)
 		return FALSE;
+
 	cbgw = (ECalBackendGroupwise *) handle;
-	priv= cbgw->priv;
+	priv = cbgw->priv;
+	if (priv->mode == CAL_MODE_LOCAL)
+		return FALSE;
+
 	kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
 	cnc = priv->cnc;
+
 	store = priv->store;
 	item_list = NULL;
 
-	if (priv->mode == CAL_MODE_LOCAL)
-		return FALSE;
-
-	attempts = e_cal_backend_store_get_key_value (store, key);
-
-	g_static_mutex_lock (&connecting);
+	attempts = g_strdup (e_cal_backend_store_get_key_value (store, ATTEMPTS_KEY));
 
 	serv_time = e_cal_backend_store_get_key_value (store, SERVER_UTC_TIME);
 	if (serv_time) {
@@ -403,31 +427,33 @@ get_deltas (gpointer handle)
 	e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EQUAL, "@type", get_element_type (kind));
 	e_gw_filter_group_conditions (filter, E_GW_FILTER_OP_AND, 2);
 
-	status = e_gw_connection_get_items (cnc, cbgw->priv->container_id, "attachments recipients message recipientStatus default peek", filter, &item_list);
+	status = e_gw_connection_get_items (cnc, priv->container_id, "attachments recipients message recipientStatus default peek", filter, &item_list);
 	if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
-		status = e_gw_connection_get_items (cnc, cbgw->priv->container_id, "attachments recipients message recipientStatus default peek", filter, &item_list);
+		status = e_gw_connection_get_items (cnc, priv->container_id, "attachments recipients message recipientStatus default peek", filter, &item_list);
+
+
 	g_object_unref (filter);
 
 	if (status != E_GW_CONNECTION_STATUS_OK) {
 
 		const gchar *msg = NULL;
+		gint failures;
 
-		if (!attempts) {
-			e_cal_backend_store_put_key_value (store, key, "2");
-		} else {
-			gint failures;
-			failures = g_ascii_strtod(attempts, NULL) + 1;
-			e_cal_backend_store_put_key_value (store, key, GINT_TO_POINTER (failures));
-		}
+		if (!attempts)
+			failures = 2;
+		else
+			failures = g_ascii_strtod (attempts, NULL) + 1;
+		g_free (attempts);
+		attempts = g_strdup_printf ("%d", failures);
+		e_cal_backend_store_put_key_value (store, ATTEMPTS_KEY, attempts);
+		g_free (attempts);
 
 		if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) {
-			g_static_mutex_unlock (&connecting);
 			return TRUE;
 		}
 
 		msg = e_gw_connection_get_error_message (status);
 
-		g_static_mutex_unlock (&connecting);
 		return TRUE;
 	}
 
@@ -499,10 +525,11 @@ get_deltas (gpointer handle)
 
 	if (attempts) {
 		tm.tm_min += (time_interval * g_ascii_strtod (attempts, NULL));
-		e_cal_backend_store_put_key_value (store, key, NULL);
+		e_cal_backend_store_put_key_value (store, ATTEMPTS_KEY, NULL);
 	} else {
 		tm.tm_min += time_interval;
 	}
+	g_free (attempts);
 	strftime (t_str, 26, "%Y-%m-%dT%H:%M:%SZ", &tm);
 	time_string = g_strdup (t_str);
 
@@ -523,17 +550,16 @@ get_deltas (gpointer handle)
 	filter = e_gw_filter_new ();
 	e_gw_filter_add_filter_component (filter, E_GW_FILTER_OP_EQUAL, "@type", get_element_type (kind));
 
-	status = e_gw_connection_create_cursor (cnc, cbgw->priv->container_id, "id iCalId recurrenceKey startDate", filter, &cursor);
+	status = e_gw_connection_create_cursor (cnc, priv->container_id, "id iCalId recurrenceKey startDate", filter, &cursor);
+
 	g_object_unref (filter);
 
 	if (status != E_GW_CONNECTION_STATUS_OK) {
 		if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) {
-			g_static_mutex_unlock (&connecting);
 			return TRUE;
 		}
 
 		e_cal_backend_groupwise_notify_error_code (cbgw, status);
-		g_static_mutex_unlock (&connecting);
 		return TRUE;
 	}
 
@@ -541,7 +567,7 @@ get_deltas (gpointer handle)
 
 	done = FALSE;
 	while (!done) {
-		status = e_gw_connection_read_cal_ids (cnc, cbgw->priv->container_id, cursor, FALSE, CURSOR_ICALID_LIMIT, position, &item_list);
+		status = e_gw_connection_read_cal_ids (cnc, priv->container_id, cursor, FALSE, CURSOR_ICALID_LIMIT, position, &item_list);
 		if (status != E_GW_CONNECTION_STATUS_OK) {
 			if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) {
 				goto err_done;
@@ -564,40 +590,25 @@ get_deltas (gpointer handle)
 		position = E_GW_CURSOR_POSITION_CURRENT;
 
 	}
-	e_gw_connection_destroy_cursor (cnc, cbgw->priv->container_id, cursor);
+	e_gw_connection_destroy_cursor (cnc, priv->container_id, cursor);
 	e_cal_backend_store_freeze_changes (store);
 
 	uid_array = g_ptr_array_new ();
 	for (l = total_list; l != NULL; l = g_list_next (l)) {
 		EGwItemCalId *calid = (EGwItemCalId *)	l->data;
 		GSList *remove = NULL;
-		ECalComponentId *id = NULL;
-
-		id = g_new0 (ECalComponentId, 1);
-
-		if (calid->recur_key && calid->start_date) {
-			gchar *rid = NULL;
-
-			icaltimetype tt = icaltime_from_string (calid->start_date);
-
-			tt = icaltime_convert_to_zone (tt, priv->default_zone);
-			icaltime_set_timezone (&tt, priv->default_zone);
-			rid = icaltime_as_ical_string_r (tt);
-
-			id->uid = g_strdup (calid->recur_key);
-			id->rid = rid;
-		} else
-			id->uid = g_strdup (calid->ical_id);
+		CompareIdData data;
 
-		if (!(remove = g_slist_find_custom (cache_ids, id,  (GCompareFunc) compare_ids))) {
+		data.calid = calid;
+		data.store = store;
+		
+		if (!(remove = g_slist_find_custom (cache_ids, &data,  (GCompareFunc) compare_ids))) {
 			g_ptr_array_add (uid_array, g_strdup (calid->item_id));
 			needs_to_get = TRUE;
 		} else  {
 			cache_ids = g_slist_remove_link (cache_ids, remove);
 			e_cal_component_free_id (remove->data);
 		}
-
-		e_cal_component_free_id (id);
 	}
 
 	for (ls = cache_ids; ls; ls = g_slist_next (ls)) {
@@ -627,10 +638,10 @@ get_deltas (gpointer handle)
 	}
 
 	if (needs_to_get) {
-		e_gw_connection_get_items_from_ids (priv->cnc,
-				priv->container_id,
-				"attachments recipients message recipientStatus default peek",
-				uid_array, &item_list);
+		e_gw_connection_get_items_from_ids (
+			cnc, priv->container_id,
+			"attachments recipients message recipientStatus recurrenceKey default peek",
+			uid_array, &item_list);
 
 		for (l = item_list; l != NULL; l = l->next) {
 			ECalComponent *comp = NULL;
@@ -641,7 +652,6 @@ get_deltas (gpointer handle)
 			comp = e_gw_item_to_cal_component (item, cbgw);
 			if (comp) {
 				e_cal_component_commit_sequence (comp);
-				sanitize_component (E_CAL_BACKEND_SYNC (cbgw), comp, (gchar *) e_gw_item_get_id (item));
 				e_cal_backend_store_put_component (store, comp);
 
 				if (kind == icalcomponent_isa (e_cal_component_get_icalcomponent (comp))) {
@@ -677,7 +687,6 @@ get_deltas (gpointer handle)
 		g_slist_free (cache_ids);
 	}
 
-	g_static_mutex_unlock (&connecting);
 	return TRUE;
 }
 
@@ -789,9 +798,9 @@ e_cal_backend_groupwise_refresh_calendar
 	if (priv->mode == CAL_MODE_LOCAL)
 		return;
 
-	g_mutex_lock (priv->mutex);
+	PRIV_LOCK (priv);
 	delta_started = fetch_deltas (cbgw);
-	g_mutex_unlock (priv->mutex);
+	PRIV_UNLOCK (priv);
 
 	/* Emit the signal if the delta is already running */
 	if (!delta_started)
@@ -890,9 +899,9 @@ cache_init (ECalBackendGroupwise *cbgw)
 		}
 	}
 
-	g_mutex_lock (priv->mutex);
+	PRIV_LOCK (priv);
 	fetch_deltas (cbgw);
-	g_mutex_unlock (priv->mutex);
+	PRIV_UNLOCK (priv);
 
 	return NULL;
 }
@@ -1075,7 +1084,6 @@ connect_to_server (ECalBackendGroupwise
 		e_cal_backend_cache_remove (uri, source_type);
 		priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
 		if (!priv->store) {
-			g_mutex_unlock (priv->mutex);
 			e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
 			return GNOME_Evolution_Calendar_OtherError;
 		}
@@ -1154,10 +1162,7 @@ e_cal_backend_groupwise_finalize (GObjec
 		priv->dthread = NULL;
 	}
 
-	if (priv->mutex) {
-		g_mutex_free (priv->mutex);
-		priv->mutex = NULL;
-	}
+	g_static_rec_mutex_free (&priv->rec_mutex);
 
 	if (priv->cnc) {
 		g_object_unref (priv->cnc);
@@ -1335,7 +1340,7 @@ e_cal_backend_groupwise_open (ECalBacken
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 	priv = cbgw->priv;
 
-	g_mutex_lock (priv->mutex);
+	PRIV_LOCK (priv);
 
 	cbgw->priv->read_only = FALSE;
 
@@ -1365,7 +1370,7 @@ e_cal_backend_groupwise_open (ECalBacken
 		display_contents = e_source_get_property (esource, "offline_sync");
 
 		if (!display_contents || !g_str_equal (display_contents, "1")) {
-			g_mutex_unlock (priv->mutex);
+			PRIV_UNLOCK (priv);
 			return GNOME_Evolution_Calendar_RepositoryOffline;
 		}
 
@@ -1376,7 +1381,7 @@ e_cal_backend_groupwise_open (ECalBacken
 			e_cal_backend_cache_remove (uri, source_type);
 			priv->store = (ECalBackendStore *) e_cal_backend_file_store_new (uri, source_type);
 			if (!priv->store) {
-				g_mutex_unlock (priv->mutex);
+				PRIV_UNLOCK (priv);
 				e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
 
 				return GNOME_Evolution_Calendar_OtherError;
@@ -1385,7 +1390,7 @@ e_cal_backend_groupwise_open (ECalBacken
 
 		e_cal_backend_store_set_default_timezone (priv->store, priv->default_zone);
 
-		g_mutex_unlock (priv->mutex);
+		PRIV_UNLOCK (priv);
 		return GNOME_Evolution_Calendar_Success;
 	}
 
@@ -1418,7 +1423,7 @@ e_cal_backend_groupwise_open (ECalBacken
 	/* FIXME: no need to set it online here when we implement the online/offline stuff correctly */
 	status = connect_to_server (cbgw);
 
-	g_mutex_unlock (priv->mutex);
+	PRIV_UNLOCK (priv);
 	return status;
 }
 
@@ -1431,13 +1436,13 @@ e_cal_backend_groupwise_remove (ECalBack
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 	priv = cbgw->priv;
 
-	g_mutex_lock (priv->mutex);
+	PRIV_LOCK (priv);
 
 	/* remove the cache */
 	if (priv->store)
 		e_cal_backend_store_remove (priv->store);
 
-	g_mutex_unlock (priv->mutex);
+	PRIV_UNLOCK (priv);
 
 	return GNOME_Evolution_Calendar_Success;
 }
@@ -1484,7 +1489,7 @@ e_cal_backend_groupwise_set_mode (ECalBa
 		return;
 	}
 
-	g_mutex_lock (priv->mutex);
+	PRIV_LOCK (priv);
 
 	priv->mode_changed = TRUE;
 	switch (mode) {
@@ -1512,7 +1517,7 @@ e_cal_backend_groupwise_set_mode (ECalBa
 					   cal_mode_to_corba (mode));
 	}
 
-	g_mutex_unlock (priv->mutex);
+	PRIV_UNLOCK (priv);
 }
 
 static ECalBackendSyncStatus
@@ -1553,12 +1558,12 @@ e_cal_backend_groupwise_get_object (ECal
 
 	priv = cbgw->priv;
 
-	g_mutex_lock (priv->mutex);
+	PRIV_LOCK (priv);
 
 	/* search the object in the cache */
 	comp = e_cal_backend_store_get_component (priv->store, uid, rid);
 	if (comp) {
-		g_mutex_unlock (priv->mutex);
+		PRIV_UNLOCK (priv);
 		if (e_cal_backend_get_kind (E_CAL_BACKEND (backend)) ==
 		    icalcomponent_isa (e_cal_component_get_icalcomponent (comp)))
 			*object = e_cal_component_get_as_string (comp);
@@ -1570,7 +1575,7 @@ e_cal_backend_groupwise_get_object (ECal
 		return *object ? GNOME_Evolution_Calendar_Success : GNOME_Evolution_Calendar_ObjectNotFound;
 	}
 
-	g_mutex_unlock (priv->mutex);
+	PRIV_UNLOCK (priv);
 
 	/* callers will never have a uuid that is in server but not in cache */
 	return GNOME_Evolution_Calendar_ObjectNotFound;
@@ -1662,12 +1667,16 @@ e_cal_backend_groupwise_set_default_zone
 	zone = icaltimezone_new ();
 	icaltimezone_set_component (zone, tz_comp);
 
+	PRIV_LOCK (priv);
+	
 	if (priv->default_zone)
 		icaltimezone_free (priv->default_zone, 1);
 
 	/* Set the default timezone to it. */
 	priv->default_zone = zone;
 
+	PRIV_UNLOCK (priv);
+
 	return GNOME_Evolution_Calendar_Success;
 }
 
@@ -1692,7 +1701,7 @@ e_cal_backend_groupwise_get_object_list
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 	priv = cbgw->priv;
 
-	g_mutex_lock (priv->mutex);
+	PRIV_LOCK (priv);
 
 	g_message (G_STRLOC ": Getting object list (%s)", sexp);
 
@@ -1701,7 +1710,7 @@ e_cal_backend_groupwise_get_object_list
 
 	cbsexp = e_cal_backend_sexp_new (sexp);
 	if (!cbsexp) {
-		g_mutex_unlock (priv->mutex);
+		PRIV_UNLOCK (priv);
 		return GNOME_Evolution_Calendar_InvalidQuery;
 	}
 
@@ -1719,11 +1728,14 @@ e_cal_backend_groupwise_get_object_list
 		}
         }
 
+	g_message (G_STRLOC ": object list length %d from %d objects",
+		   g_list_length (*objects), g_slist_length (components));
+
 	g_object_unref (cbsexp);
 	g_slist_foreach (components, (GFunc) g_object_unref, NULL);
 	g_slist_free (components);
 
-	g_mutex_unlock (priv->mutex);
+	PRIV_UNLOCK (priv);
 
 	return GNOME_Evolution_Calendar_Success;
 }
@@ -1778,10 +1790,10 @@ e_cal_backend_groupwise_get_free_busy (E
 	       return GNOME_Evolution_Calendar_RepositoryOffline;
        }
 
-       status = e_gw_connection_get_freebusy_info (cnc, users, start, end, freebusy, cbgw->priv->default_zone);
+       status = e_gw_connection_get_freebusy_info (cbgw, users, start, end, freebusy);
 
        if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
-	       status = e_gw_connection_get_freebusy_info (cnc, users, start, end, freebusy, cbgw->priv->default_zone);
+	       status = e_gw_connection_get_freebusy_info (cbgw, users, start, end, freebusy);
 
        if (status != E_GW_CONNECTION_STATUS_OK)
                return GNOME_Evolution_Calendar_OtherError;
@@ -1918,7 +1930,12 @@ e_cal_backend_groupwise_internal_get_def
 static icaltimezone *
 e_cal_backend_groupwise_internal_get_timezone (ECalBackend *backend, const gchar *tzid)
 {
-	icaltimezone *zone;
+	icaltimezone *zone = NULL;
+	ECalBackendGroupwise *cbgw;
+
+	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
+	g_return_val_if_fail (cbgw != NULL, NULL);
+	g_return_val_if_fail (cbgw->priv != NULL, NULL);
 
 	zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
 
@@ -1931,36 +1948,6 @@ e_cal_backend_groupwise_internal_get_tim
 	return zone;
 }
 
-static void
-sanitize_component (ECalBackendSync *backend, ECalComponent *comp, gchar *server_uid)
-{
-	ECalBackendGroupwise *cbgw;
-	icalproperty *icalprop;
-	gint i;
-	GString *str = g_string_new ("");;
-
-	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
-	if (server_uid) {
-
-		/* the ID returned by sendItemResponse includes the container ID of the
-		   inbox folder, so we need to replace that with our container ID */
-		for (i = 0; i < strlen (server_uid); i++) {
-			str = g_string_append_c (str, server_uid[i]);
-			if (server_uid[i] == ':') {
-				str = g_string_append (str, cbgw->priv->container_id);
-				break;
-			}
-		}
-
-		/* add the extra property to the component */
-		icalprop = icalproperty_new_x (str->str);
-		icalproperty_set_x_name (icalprop, "X-GWRECORDID");
-		icalcomponent_add_property (e_cal_component_get_icalcomponent (comp), icalprop);
-
-	}
-	g_string_free (str, TRUE);
-}
-
 static EGwConnectionStatus
 update_from_server (ECalBackendGroupwise *cbgw, GSList *uid_list, gchar **calobj, ECalComponent *comp)
 {
@@ -1999,7 +1986,6 @@ update_from_server (ECalBackendGroupwise
 		item = (EGwItem *) tmp->data;
 		e_cal_comp = e_gw_item_to_cal_component (item, cbgw);
 		e_cal_component_commit_sequence (e_cal_comp);
-		sanitize_component (backend, e_cal_comp, g_ptr_array_index (uid_array, i));
 		e_cal_backend_store_put_component (priv->store, e_cal_comp);
 
 		if (i == 0) {
@@ -2839,7 +2825,7 @@ e_cal_backend_groupwise_init (ECalBacken
 	priv->sendoptions_sync_timeout = 0;
 
 	/* create the mutex for thread safety */
-	priv->mutex = g_mutex_new ();
+	g_static_rec_mutex_init (&priv->rec_mutex);
 
 	cbgw->priv = priv;
 
Index: evolution-data-server-2.28.2/calendar/backends/groupwise/e-cal-backend-groupwise.h
===================================================================
--- evolution-data-server-2.28.2.orig/calendar/backends/groupwise/e-cal-backend-groupwise.h
+++ evolution-data-server-2.28.2/calendar/backends/groupwise/e-cal-backend-groupwise.h
@@ -62,7 +62,11 @@ GHashTable* e_cal_backend_groupwise_get_
 GHashTable* e_cal_backend_groupwise_get_categories_by_name (ECalBackendGroupwise *cbgw);
 icaltimezone* e_cal_backend_groupwise_get_default_zone (ECalBackendGroupwise *cbgw);
 void    e_cal_backend_groupwise_notify_error_code (ECalBackendGroupwise *cbgw, EGwConnectionStatus status);
+const gchar *e_cal_backend_groupwise_get_container_id (ECalBackendGroupwise *cbgw);
 const gchar * e_cal_backend_groupwise_get_local_attachments_store (ECalBackendGroupwise *cbgw);
+void e_cal_backend_groupwise_priv_lock (ECalBackendGroupwise *cbgw);
+void e_cal_backend_groupwise_priv_unlock (ECalBackendGroupwise *cbgw);
+
 G_END_DECLS
 
 #endif
