diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index 99d2390..55696d5 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -3270,6 +3270,7 @@ camel_folder_get_message_sync (CamelFolder *folder,
 	/* Check for cancellation after locking. */
 	if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
 		camel_folder_unlock (folder, CAMEL_FOLDER_REC_LOCK);
+		camel_operation_pop_message (cancellable);
 		return NULL;
 	}
 
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 1563bb3..494aead 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -233,6 +233,7 @@ struct _CamelIMAPXJob {
 
 	GCancellable *cancellable;
 	GError *error;
+	gboolean with_operation_msg;
 
 	void (*start)(CamelIMAPXServer *is, struct _CamelIMAPXJob *job);
 
@@ -2141,16 +2142,38 @@ imapx_job_new (GCancellable *cancellable)
 }
 
 static void
+imapx_job_free (CamelIMAPXJob *job)
+{
+	if (!job)
+		return;
+
+	g_clear_error (&job->error);
+
+	if (job->cancellable) {
+		if (job->with_operation_msg)
+			camel_operation_pop_message (job->cancellable);
+		g_object_unref (job->cancellable);
+	}
+
+	g_free (job);
+}
+
+static gboolean
+imapx_job_can_operation_msg (CamelIMAPXJob *job)
+{
+	return job && job->cancellable && CAMEL_IS_OPERATION (job->cancellable);
+}
+
+static void
 imapx_job_done (CamelIMAPXServer *is, CamelIMAPXJob *job)
 {
 	QUEUE_LOCK (is);
 	camel_dlist_remove ((CamelDListNode *) job);
 	QUEUE_UNLOCK (is);
 
-	if (job->noreply) {
-		g_clear_error (&job->error);
-		g_free (job);
-	} else
+	if (job->noreply)
+		imapx_job_free (job);
+	else
 		camel_msgport_reply ((CamelMsg *) job);
 }
 
@@ -2220,6 +2243,26 @@ imapx_submit_job (CamelIMAPXServer *is,
 	return imapx_run_job (is, job, error);
 }
 
+static void
+propagate_ic_error (CamelIMAPXJob *job, CamelIMAPXCommand *ic, const gchar *fmt)
+{
+	g_return_if_fail (job != NULL);
+	g_return_if_fail (ic != NULL);
+	g_return_if_fail (fmt != NULL);
+
+	if (job->error)
+		return;
+
+	if (ic->error == NULL) {
+		g_set_error (
+			&job->error, CAMEL_IMAPX_ERROR, 1,
+			fmt, ic->status && ic->status->text ? ic->status->text : "Uknown error");
+	} else {
+		g_propagate_error (&job->error, ic->error);
+		ic->error = NULL;
+	}
+}
+
 /* ********************************************************************** */
 // IDLE support
 
@@ -2249,14 +2292,7 @@ imapx_command_idle_done (CamelIMAPXServer *is,
 	CamelIMAPXIdle *idle = is->idle;
 
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&ic->job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error performing IDLE: %s", ic->status->text);
-		else {
-			g_propagate_error (&ic->job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (ic->job, ic, "Error performing IDLE: %s");
 	}
 
 	IDLE_LOCK (idle);
@@ -2315,7 +2351,7 @@ camel_imapx_server_idle (CamelIMAPXServer *is,
 
 	success = imapx_submit_job (is, job, error);
 
-	g_free (job);
+	imapx_job_free (job);
 
 	return success;
 }
@@ -2342,7 +2378,7 @@ imapx_server_fetch_new_messages (CamelIMAPXServer *is,
 	success = imapx_submit_job (is, job, error);
 
 	if (!async)
-		g_free (job);
+		imapx_job_free (job);
 
 	return success;
 }
@@ -3334,16 +3370,10 @@ imapx_command_fetch_message_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		CamelStream *stream = job->u.get_message.stream;
 
 		/* return the exception from last command */
-		if (failed) {
-			if (ic->error == NULL)
-				g_set_error (
-					&job->error, CAMEL_IMAPX_ERROR, 1,
-					"Error fetching message: %s", ic->status->text);
-			else {
-				g_propagate_error (&job->error, ic->error);
-				ic->error = NULL;
-			}
-			g_object_unref (stream);
+		if (failed || job->error) {
+			propagate_ic_error (job, ic, "Error fetching message: %s");
+			if (stream)
+				g_object_unref (stream);
 			job->u.get_message.stream = NULL;
 		} else {
 			CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) job->folder;
@@ -3370,6 +3400,7 @@ imapx_command_fetch_message_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 						_("Closing tmp stream failed: "));
 
 				g_free (tmp);
+				g_object_unref (job->u.get_message.stream);
 				job->u.get_message.stream = camel_data_cache_get (ifolder->cache, "cur", job->u.get_message.uid, NULL);
 			}
 		}
@@ -3461,15 +3492,7 @@ imapx_command_copy_messages_step_done (CamelIMAPXServer *is,
 	GPtrArray *uids = job->u.copy_messages.uids;
 
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error copying messages");
-		else {
-			g_propagate_error (&job->error, ic->error);
-			ic->error = NULL;
-		}
-
+		propagate_ic_error (job, ic, "Error copying messages");
 		goto cleanup;
 	}
 
@@ -3570,14 +3593,7 @@ imapx_command_append_message_done (CamelIMAPXServer *is,
 			}
 		}
 	} else {
-		if (ic->error == NULL)
-			g_set_error (
-				&job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error appending message: %s", ic->status->text);
-		else {
-			g_propagate_error (&job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (job, ic, "Error appending message: %s");
 	}
 
 	camel_data_cache_remove (ifolder->cache, "new", old_uid, NULL);
@@ -3695,15 +3711,7 @@ imapx_command_step_fetch_done (CamelIMAPXServer *is,
 	GArray *infos = job->u.refresh_info.infos;
 
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error fetching message headers");
-		else {
-			g_propagate_error (&job->error, ic->error);
-			ic->error = NULL;
-		}
-
+		propagate_ic_error (job, ic, "Error fetching message headers");
 		goto cleanup;
 	}
 
@@ -3935,10 +3943,15 @@ imapx_job_scan_changes_done (CamelIMAPXServer *is,
 
 		/* If we have any new messages, download their headers, but only a few (100?) at a time */
 		if (fetch_new) {
-			camel_operation_push_message (
-				job->cancellable,
-				_("Fetching summary information for new messages in %s"),
-				camel_folder_get_display_name (job->folder));
+			if (imapx_job_can_operation_msg (job)) {
+				job->with_operation_msg = TRUE;
+
+				camel_operation_push_message (
+					job->cancellable,
+					_("Fetching summary information for new messages in %s"),
+					camel_folder_get_display_name (job->folder));
+			}
+
 			imapx_uidset_init (&job->u.refresh_info.uidset, get_batch_fetch_count (is), 0);
 			/* These are new messages which arrived since we last knew the unseen count;
 			   update it as they arrive. */
@@ -3947,14 +3960,7 @@ imapx_job_scan_changes_done (CamelIMAPXServer *is,
 			return;
 		}
 	} else {
-		if (ic->error == NULL)
-			g_set_error (
-				&job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error retriving message: %s", ic->status->text);
-		else {
-			g_propagate_error (&job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (job, ic, "Error retriving message: %s");
 	}
 
 	for (i=0;i<infos->len;i++) {
@@ -3979,10 +3985,14 @@ imapx_job_scan_changes_start (CamelIMAPXServer *is,
 {
 	CamelIMAPXCommand *ic;
 
-	camel_operation_push_message (
-		job->cancellable,
-		_("Scanning for changed messages in %s"),
-		camel_folder_get_display_name (job->folder));
+	if (imapx_job_can_operation_msg (job)) {
+		job->with_operation_msg = TRUE;
+
+		camel_operation_push_message (
+			job->cancellable,
+			_("Scanning for changed messages in %s"),
+			camel_folder_get_display_name (job->folder));
+	}
 
 	ic = camel_imapx_command_new (
 		is, "FETCH", job->folder, job->cancellable,
@@ -4002,14 +4012,7 @@ imapx_command_fetch_new_messages_done (CamelIMAPXServer *is,
 	CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) ic->job->folder;
 
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&ic->job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error fetching new messages: %s", ic->status->text);
-		else {
-			g_propagate_error (&ic->job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (ic->job, ic, "Error fetching new messages: %s");
 		goto exception;
 	}
 
@@ -4077,10 +4080,14 @@ imapx_job_fetch_new_messages_start (CamelIMAPXServer *is,
 	} else
 		uid = g_strdup ("1");
 
-	camel_operation_push_message (
-		job->cancellable,
-		_("Fetching summary information for new messages in %s"),
-		camel_folder_get_display_name (folder));
+	if (imapx_job_can_operation_msg (job)) {
+		job->with_operation_msg = TRUE;
+
+		camel_operation_push_message (
+			job->cancellable,
+			_("Fetching summary information for new messages in %s"),
+			camel_folder_get_display_name (folder));
+	}
 
 	if (diff > get_batch_fetch_count (is) || is->descending) {
 		ic = camel_imapx_command_new (
@@ -4195,15 +4202,7 @@ imapx_job_refresh_info_start (CamelIMAPXServer *is,
 			imapx_command_run_sync (is, ic);
 
 			if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-				if (ic->error == NULL)
-					g_set_error (
-						&job->error, CAMEL_IMAPX_ERROR, 1,
-						"Error refreshing folder: %s", ic->status->text);
-				else {
-					g_propagate_error (&job->error, ic->error);
-					ic->error = NULL;
-				}
-
+				propagate_ic_error (job, ic, "Error refreshing folder: %s");
 				camel_imapx_command_free (ic);
 				goto done;
 			}
@@ -4285,14 +4284,7 @@ imapx_command_expunge_done (CamelIMAPXServer *is,
                             CamelIMAPXCommand *ic)
 {
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&ic->job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error expunging message: %s", ic->status->text);
-		else {
-			g_propagate_error (&ic->job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (ic->job, ic, "Error expunging message: %s");
 	} else {
 		GPtrArray *uids;
 		CamelFolder *folder = ic->job->folder;
@@ -4367,14 +4359,7 @@ imapx_command_list_done (CamelIMAPXServer *is,
                          CamelIMAPXCommand *ic)
 {
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&ic->job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error fetching folders: %s", ic->status->text);
-		else {
-			g_propagate_error (&ic->job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (ic->job, ic, "Error fetching folders: %s");
 	}
 
 	e (is->tagprefix, "==== list or lsub completed ==== \n");
@@ -4426,14 +4411,7 @@ imapx_command_subscription_done (CamelIMAPXServer *is,
                                  CamelIMAPXCommand *ic)
 {
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&ic->job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error subscribing to folder : %s", ic->status->text);
-		else {
-			g_propagate_error (&ic->job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (ic->job, ic, "Error subscribing to folder: %s");
 	}
 
 	imapx_job_done (is, ic->job);
@@ -4475,14 +4453,7 @@ imapx_command_create_folder_done (CamelIMAPXServer *is,
                                   CamelIMAPXCommand *ic)
 {
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&ic->job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error creating to folder: %s", ic->status->text);
-		else {
-			g_propagate_error (&ic->job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (ic->job, ic, "Error creating to folder: %s");
 	}
 
 	imapx_job_done (is, ic->job);
@@ -4515,14 +4486,7 @@ imapx_command_delete_folder_done (CamelIMAPXServer *is,
                                   CamelIMAPXCommand *ic)
 {
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&ic->job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error deleting to folder : %s", ic->status->text);
-		else {
-			g_propagate_error (&ic->job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (ic->job, ic, "Error deleting to folder: %s");
 	}
 
 	imapx_job_done (is, ic->job);
@@ -4560,14 +4524,7 @@ imapx_command_rename_folder_done (CamelIMAPXServer *is,
                                   CamelIMAPXCommand *ic)
 {
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&ic->job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error renaming to folder: %s", ic->status->text);
-		else {
-			g_propagate_error (&ic->job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (ic->job, ic, "Error renaming folder: %s");
 	}
 
 	imapx_job_done (is, ic->job);
@@ -4606,14 +4563,7 @@ imapx_command_noop_done (CamelIMAPXServer *is,
                          CamelIMAPXCommand *ic)
 {
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
-		if (ic->error == NULL)
-			g_set_error (
-				&ic->job->error, CAMEL_IMAPX_ERROR, 1,
-				"Error performing NOOP: %s", ic->status->text);
-		else {
-			g_propagate_error (&ic->job->error, ic->error);
-			ic->error = NULL;
-		}
+		propagate_ic_error (ic->job, ic, "Error performing NOOP: %s");
 	}
 
 	imapx_job_done (is, ic->job);
@@ -4689,14 +4639,7 @@ imapx_command_sync_changes_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 
 	if (ic->error != NULL || ic->status->result != IMAPX_OK) {
 		if (!job->error) {
-			if (ic->error == NULL)
-				g_set_error (
-					&job->error, CAMEL_IMAPX_ERROR, 1,
-					"Error syncing changes: %s", ic->status->text);
-			else {
-				g_propagate_error (&job->error, ic->error);
-				ic->error = NULL;
-			}
+			propagate_ic_error (job, ic, "Error syncing changes: %s");
 		} else if (ic->error) {
 			g_clear_error (&ic->error);
 		}
@@ -5348,7 +5291,7 @@ imapx_server_get_message (CamelIMAPXServer *is,
 	else if (job->u.get_message.stream != NULL)
 		g_object_unref (job->u.get_message.stream);
 
-	g_free (job);
+	imapx_job_free (job);
 
 	g_mutex_lock (is->fetch_mutex);
 	is->fetch_count++;
@@ -5506,7 +5449,7 @@ camel_imapx_server_append_message (CamelIMAPXServer *is,
 
 	success = imapx_submit_job (is, job, error);
 
-	g_free (job);
+	imapx_job_free (job);
 
 	return success;
 }
@@ -5528,7 +5471,7 @@ camel_imapx_server_noop (CamelIMAPXServer *is,
 
 	success = imapx_submit_job (is, job, error);
 
-	g_free (job);
+	imapx_job_free (job);
 
 	return success;
 }
@@ -5574,9 +5517,7 @@ camel_imapx_server_refresh_info (CamelIMAPXServer *is,
 
 	camel_folder_change_info_free (job->u.refresh_info.changes);
 
-	if (job->cancellable)
-		g_object_unref (job->cancellable);
-	g_free (job);
+	imapx_job_free (job);
 
 	return success;
 }
@@ -5752,7 +5693,7 @@ imapx_server_sync_changes (CamelIMAPXServer *is,
 
 	success = registered && imapx_run_job (is, job, error);
 
-	g_free (job);
+	imapx_job_free (job);
 
 done:
 	imapx_sync_free_user (on_user);
@@ -5805,7 +5746,7 @@ camel_imapx_server_expunge (CamelIMAPXServer *is,
 
 	success = registered && imapx_run_job (is, job, error);
 
-	g_free (job);
+	imapx_job_free (job);
 
 	return success;
 }
@@ -5887,7 +5828,7 @@ camel_imapx_server_list (CamelIMAPXServer *is,
 
 	g_hash_table_destroy (job->u.list.folders);
 	g_free (encoded_name);
-	g_free (job);
+	imapx_job_free (job);
 
 	return folders;
 }
@@ -5911,7 +5852,7 @@ camel_imapx_server_manage_subscription (CamelIMAPXServer *is,
 
 	success = imapx_submit_job (is, job, error);
 
-	g_free (job);
+	imapx_job_free (job);
 
 	return success;
 }
@@ -5933,7 +5874,7 @@ camel_imapx_server_create_folder (CamelIMAPXServer *is,
 
 	success = imapx_submit_job (is, job, error);
 
-	g_free (job);
+	imapx_job_free (job);
 
 	return success;
 }
@@ -5955,7 +5896,7 @@ camel_imapx_server_delete_folder (CamelIMAPXServer *is,
 
 	success = imapx_submit_job (is, job, error);
 
-	g_free (job);
+	imapx_job_free (job);
 
 	return success;
 }
@@ -5979,7 +5920,7 @@ camel_imapx_server_rename_folder (CamelIMAPXServer *is,
 
 	success = imapx_submit_job (is, job, error);
 
-	g_free (job);
+	imapx_job_free (job);
 
 	return success;
 }
