diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index efab037..10a6880 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -167,7 +167,6 @@ static CamelLocalSummary *maildir_create_summary(CamelLocalFolder *lf, const gch
 static void
 maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex)
 {
-	CamelMaildirFolder *maildir_folder = (CamelMaildirFolder *)folder;
 	CamelLocalFolder *lf = (CamelLocalFolder *)folder;
 	CamelStream *output_stream;
 	CamelMessageInfo *mi;
@@ -176,10 +175,17 @@ maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const Ca
 
 	d(printf("Appending message\n"));
 
+	/* If we can't lock, don't do anything */
+	if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, ex) == -1)
+		return;
+
+	if (camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, ex) == -1)
+		goto check_changed;
+
 	/* add it to the summary/assign the uid, etc */
 	mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
 	if (camel_exception_is_set (ex))
-		return;
+		goto check_changed;
 
 	if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
 		camel_message_info_set_flags (mi, CAMEL_MESSAGE_ATTACHMENTS, 0);
@@ -206,17 +212,13 @@ maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const Ca
 	g_free (dest);
 	g_free (name);
 
-	camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed",
-				    ((CamelLocalFolder *)maildir_folder)->changes);
-	camel_folder_change_info_clear (((CamelLocalFolder *)maildir_folder)->changes);
-
 	if (appended_uid)
 		*appended_uid = g_strdup(camel_message_info_uid(mi));
 
 	if (output_stream)
 		camel_object_unref (output_stream);
 
-	return;
+	goto check_changed;
 
  fail_write:
 
@@ -239,6 +241,14 @@ maildir_append_message (CamelFolder *folder, CamelMimeMessage *message, const Ca
 
 	g_free (name);
 	g_free (dest);
+
+ check_changed:
+	camel_local_folder_unlock (lf);
+
+	if (lf && camel_folder_change_info_changed (lf->changes)) {
+		camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", lf->changes);
+		camel_folder_change_info_clear (lf->changes);
+	}
 }
 
 static gchar *
@@ -270,17 +280,24 @@ maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex
 	CamelStream *message_stream = NULL;
 	CamelMimeMessage *message = NULL;
 	CamelMessageInfo *info;
-	gchar *name;
+	gchar *name = NULL;
 	CamelMaildirMessageInfo *mdi;
 
 	d(printf("getting message: %s\n", uid));
 
+	if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, ex) == -1)
+		return NULL;
+
+	if (camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, ex) == -1) {
+		goto fail;
+	}
+
 	/* get the message summary info */
 	if ((info = camel_folder_summary_uid(folder->summary, uid)) == NULL) {
 		camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
 				     _("Cannot get message: %s from folder %s\n  %s"),
 				     uid, lf->folder_path, _("No such message"));
-		return NULL;
+		goto fail;
 	}
 
 	mdi = (CamelMaildirMessageInfo *)info;
@@ -294,8 +311,7 @@ maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex
 		camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM,
 				     _("Cannot get message: %s from folder %s\n  %s"),
 				     uid, lf->folder_path, g_strerror(errno));
-		g_free(name);
-		return NULL;
+		goto fail;
 	}
 
 	message = camel_mime_message_new();
@@ -303,14 +319,20 @@ maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex
 		camel_exception_setv(ex, (errno==EINTR)?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM,
 				     _("Cannot get message: %s from folder %s\n  %s"),
 				     uid, lf->folder_path, _("Invalid message contents"));
-		g_free(name);
-		camel_object_unref((CamelObject *)message_stream);
 		camel_object_unref((CamelObject *)message);
-		return NULL;
+		message = NULL;
 
 	}
 	camel_object_unref((CamelObject *)message_stream);
-	g_free(name);
+ fail:
+	g_free (name);
+
+	camel_local_folder_unlock (lf);
+
+	if (lf && camel_folder_change_info_changed (lf->changes)) {
+		camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", lf->changes);
+		camel_folder_change_info_clear (lf->changes);
+	}
 
 	return message;
 }
diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c
index d3aa951..fa88e37 100644
--- a/camel/providers/local/camel-mh-folder.c
+++ b/camel/providers/local/camel-mh-folder.c
@@ -126,7 +126,6 @@ static CamelLocalSummary *mh_create_summary(CamelLocalFolder *lf, const gchar *p
 static void
 mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex)
 {
-	CamelMhFolder *mh_folder = (CamelMhFolder *)folder;
 	CamelLocalFolder *lf = (CamelLocalFolder *)folder;
 	CamelStream *output_stream;
 	CamelMessageInfo *mi;
@@ -136,10 +135,17 @@ mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMe
 
 	d(printf("Appending message\n"));
 
+	/* If we can't lock, don't do anything */
+	if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, ex) == -1)
+		return;
+
+	if (camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, ex) == -1)
+		goto check_changed;
+
 	/* add it to the summary/assign the uid, etc */
 	mi = camel_local_summary_add((CamelLocalSummary *)folder->summary, message, info, lf->changes, ex);
 	if (camel_exception_is_set (ex))
-		return;
+		goto check_changed;
 
 	if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message))
 		camel_message_info_set_flags (mi, CAMEL_MESSAGE_ATTACHMENTS, 0);
@@ -161,14 +167,10 @@ mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMe
 
 	g_free(name);
 
-	camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed",
-				    ((CamelLocalFolder *)mh_folder)->changes);
-	camel_folder_change_info_clear (((CamelLocalFolder *)mh_folder)->changes);
-
 	if (appended_uid)
 		*appended_uid = g_strdup(camel_message_info_uid(mi));
 
-	return;
+	goto check_changed;
 
  fail_write:
 
@@ -190,6 +192,14 @@ mh_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMe
 	}
 
 	g_free (name);
+
+ check_changed:
+	camel_local_folder_unlock (lf);
+
+	if (lf && camel_folder_change_info_changed (lf->changes)) {
+		camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", lf->changes);
+		camel_folder_change_info_clear (lf->changes);
+	}
 }
 
 static gchar * mh_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
@@ -206,16 +216,23 @@ static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid,
 	CamelStream *message_stream = NULL;
 	CamelMimeMessage *message = NULL;
 	CamelMessageInfo *info;
-	gchar *name;
+	gchar *name = NULL;
 
 	d(printf("getting message: %s\n", uid));
 
+	if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, ex) == -1)
+		return NULL;
+
+	if (camel_local_summary_check ((CamelLocalSummary *)folder->summary, lf->changes, ex) == -1) {
+		goto fail;
+	}
+
 	/* get the message summary info */
 	if ((info = camel_folder_summary_uid(folder->summary, uid)) == NULL) {
 		camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
 				     _("Cannot get message: %s from folder %s\n  %s"), uid, lf->folder_path,
 				     _("No such message"));
-		return NULL;
+		goto fail;
 	}
 
 	/* we only need it to check the message exists */
@@ -226,8 +243,7 @@ static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid,
 		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
 				      _("Cannot get message: %s from folder %s\n  %s"), name, lf->folder_path,
 				      g_strerror (errno));
-		g_free(name);
-		return NULL;
+		goto fail;
 	}
 
 	message = camel_mime_message_new();
@@ -235,14 +251,21 @@ static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid,
 		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
 				      _("Cannot get message: %s from folder %s\n  %s"), name, lf->folder_path,
 				      _("Message construction failed."));
-		g_free(name);
-		camel_object_unref((CamelObject *)message_stream);
 		camel_object_unref((CamelObject *)message);
-		return NULL;
+		message = NULL;
 
 	}
 	camel_object_unref((CamelObject *)message_stream);
-	g_free(name);
+
+ fail:
+	g_free (name);
+
+	camel_local_folder_unlock (lf);
+
+	if (lf && camel_folder_change_info_changed (lf->changes)) {
+		camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", lf->changes);
+		camel_folder_change_info_clear (lf->changes);
+	}
 
 	return message;
 }
