diff --git a/camel/camel-exchange-utils.c b/camel/camel-exchange-utils.c
index bf9405c..cd26c7f 100644
--- a/camel/camel-exchange-utils.c
+++ b/camel/camel-exchange-utils.c
@@ -154,12 +154,26 @@ is_same_ed (CamelExchangeStore *estore, ExchangeAccount *eaccount, CamelService
 
 static void free_folder (gpointer value);
 
+G_LOCK_DEFINE_STATIC (edies);
+
+static void
+estore_finalize_hook_cb (CamelObject *object, gpointer event_data, gpointer ediesptr)
+{
+	GSList **edies = ediesptr;
+
+	printf ("%s: finalizing store '%p'\n", __FUNCTION__, object);
+
+	g_return_if_fail (edies != NULL);
+
+	G_LOCK (edies);
+	*edies = g_slist_remove (*edies, object);
+	G_UNLOCK (edies);
+}
+
 static ExchangeData *
 get_data_for_service (CamelService *service)
 {
 	static GSList *edies = NULL;
-	G_LOCK_DEFINE_STATIC (edies);
-
 	GSList *p, *accounts;
 	ExchangeData *res = NULL;
 
@@ -183,12 +197,15 @@ get_data_for_service (CamelService *service)
 		if (a && is_same_ed (NULL, a, service)) {
 			res = g_new0 (ExchangeData, 1);
 			res->account = a;
-			if (CAMEL_IS_EXCHANGE_STORE (service))
+			if (CAMEL_IS_EXCHANGE_STORE (service)) {
 				res->estore = CAMEL_EXCHANGE_STORE (service);
+				camel_object_hook_event (res->estore, "finalize", estore_finalize_hook_cb, &edies);
+			}
 			res->folders_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, free_folder);
 			g_static_rec_mutex_init (&res->changed_msgs_mutex);
 
 			edies = g_slist_prepend (edies, res);
+			printf ("%s: adding ed %p for %p service with %p estore\n", __FUNCTION__, res, service, res->estore);
 			break;
 		}
 	}
@@ -197,6 +214,7 @@ get_data_for_service (CamelService *service)
 
 	G_UNLOCK (edies);
 
+	printf ("%s: returning %p for service %p which is '%s'\n", __FUNCTION__, res, service, camel_type_to_name (CAMEL_OBJECT_GET_TYPE (service)));
 	return res;
 }
 
