diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index 760c21d..198c022 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -95,7 +95,8 @@ camel_imapx_folder_new(CamelStore *store, const gchar *folder_dir, const gchar *
 	ifolder->ignore_recent = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, NULL);
 	ifolder->exists_on_server = 0;
 	ifolder->unread_on_server = 0;
-	ifolder->modseq_on_server = 0;
+	ifolder->last_known_modseq = ifolder->modseq_on_server = 0;
+	ifolder->last_known_uidnext = ifolder->uidnext_on_sever = 0;
 
 	istore = (CamelIMAPXStore *) store;
 	if (!g_ascii_strcasecmp (folder_name, "INBOX")) {
diff --git a/camel/providers/imapx/camel-imapx-folder.h b/camel/providers/imapx/camel-imapx-folder.h
index 31318c9..c28b5b1 100644
--- a/camel/providers/imapx/camel-imapx-folder.h
+++ b/camel/providers/imapx/camel-imapx-folder.h
@@ -60,7 +60,9 @@ struct _CamelIMAPXFolder {
 	guint32 exists_on_server;
 	guint32 unread_on_server;
 	guint32 modseq_on_server;
+	guint32 uidnext_on_server;
 
+	guint32 last_known_uidnext;
 	guint32 last_known_modseq; /* When we last fetched flags */
 
 	/* hash table of UIDs to ignore as recent when updating folder */
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index b36eb16..48972e1 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -32,8 +32,8 @@
 #include <ws2tcpip.h>
 #endif
 
-#define c(x)
-#define e(x)
+#define c(x) x
+#define e(x) x
 
 #define CFS_CLASS(x) ((CamelFolderSummaryClass *)((CamelObject *)x)->klass)
 
@@ -1102,6 +1102,10 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 		if (imap->select_folder) {
 			gchar *uid = NULL;
 			CamelMessageInfo *mi;
+			CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *)imap->select_folder;
+
+			if (ifolder->exists_on_server)
+				ifolder->exists_on_server--;
 
 			uid = camel_folder_summary_uid_from_index (imap->select_folder->summary, expunge - 1);
 			if (!uid)
@@ -1388,6 +1392,7 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 			imap->exists = sinfo->messages;
 			imap->unread = sinfo->unseen;
 			imap->highestmodseq = sinfo->highestmodseq;
+			imap->uidnext = sinfo->uidnext;
 
 			g_free (sinfo);
 		}
@@ -1426,6 +1431,9 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 		case IMAPX_PERMANENTFLAGS:
 			imap->permanentflags = sinfo->u.permanentflags;
 			break;
+		case IMAPX_UIDNEXT:
+			imap->uidnext = sinfo->u.uidnext;
+			break;
 		case IMAPX_ALERT:
 			c(printf("ALERT!: %s\n", sinfo->text));
 			break;
@@ -1712,6 +1720,7 @@ imapx_command_status_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 	ifolder->unread_on_server = is->unread;
 	ifolder->exists_on_server = is->exists;
 	ifolder->modseq_on_server = is->highestmodseq;
+	ifolder->uidnext_on_server = is->uidnext;
 
 	e_flag_set (ic->flag);
 }
@@ -2074,6 +2083,7 @@ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		is->state = IMAPX_SELECTED;
 		ifolder->exists_on_server = is->exists;
 		ifolder->modseq_on_server = is->highestmodseq;
+		ifolder->uidnext_on_server = is->uidnext;
 #if 0
 		/* This must trigger a complete index rebuild! */
 		if (is->uidvalidity && is->uidvalidity != ((CamelIMAPXSummary *)is->select_folder->summary)->uidvalidity)
@@ -3135,12 +3145,18 @@ imapx_job_scan_changes_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		CamelMessageInfo *s_minfo = NULL;
 		CamelIMAPXMessageInfo *info;
 		CamelFolderSummary *s = job->folder->summary;
+		CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *)job->folder;
 		GSList *removed = NULL, *l;
 		gboolean fetch_new = FALSE;
 		gint i;
 		guint j = 0;
 		GPtrArray *uids;
 
+		/* Actually we wanted to do this after the SELECT but before the
+		   FETCH command was issued. But this should suffice. */
+		ifolder->last_known_uidnext = ifolder->uidnext_on_server;
+		ifolder->last_known_modseq = ifolder->modseq_on_server;
+
 		/* Here we do the typical sort/iterate/merge loop.
 		   If the server flags dont match what we had, we modify our
 		   flags to pick up what the server now has - but we merge
@@ -3269,6 +3285,10 @@ imapx_job_scan_changes_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		g_free(r->uid);
 	}
 
+	/* There's no sane way to get the server-side unseen count on the
+	   select mailbox. So just work it out from the flags */
+	((CamelIMAPXFolder *)job->folder)->unread_on_server = job->folder->summary->unread_count;
+
 	g_array_free(job->u.refresh_info.infos, TRUE);
 	imapx_job_done (is, job);
 	camel_imapx_command_free (ic);
@@ -3350,7 +3370,7 @@ imapx_job_fetch_new_messages_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
 
 	if (diff > BATCH_FETCH_COUNT) {
 		ic = camel_imapx_command_new ("FETCH", full_name,
-				     "FETCH %s:* (UID FLAGS)", uid);
+				     "UID FETCH %s:* (UID FLAGS)", uid);
 		imapx_uidset_init(&job->u.refresh_info.uidset, BATCH_FETCH_COUNT, 0);
 		job->u.refresh_info.infos = g_array_new (0, 0, sizeof(struct _refresh_info));
 		ic->pri = job->pri;
@@ -3375,73 +3395,100 @@ imapx_job_refresh_info_start (CamelIMAPXServer *is, CamelIMAPXJob *job)
 	CamelFolder *folder = job->folder;
 	CamelException *ex = job->ex;
 	const gchar *full_name;
+	gboolean need_rescan = FALSE;
+	gboolean is_selected = FALSE;
 
 	full_name = camel_folder_get_full_name (folder);
 
-	total = camel_folder_summary_count (folder->summary);
-	/* Check if there are any new messages. The old imap doc says one needs to reselect in case of inbox to fetch
-	   new messages. Need to check if its still true. Just use noop now */
-	if (ifolder->exists_on_server == total) {
-		camel_imapx_server_noop (is, folder, ex);
-
-		if (camel_exception_is_set (ex))
-			goto exception;
-	}
-
-	/* Fetch the new messages */
-	if (ifolder->exists_on_server > total)
-	{
-		imapx_server_fetch_new_messages (is, folder, FALSE, job->ex);
-		if (camel_exception_is_set (job->ex))
-			goto exception;
-	}
-
-	/* Sync changes before fetching status, else unread count will not match. need to think about better ways for this */
+	/* Sync changes first, else unread count will not
+	   match. Need to think about better ways for this */
 	imapx_server_sync_changes (is, folder, job->pri, ex);
 	if (camel_exception_is_set (job->ex))
 		goto exception;
 
-	/* Check if a rescan is needed */
+	if (is->select && !strcmp(full_name, is->select))
+		is_selected = TRUE;
+
 	total = camel_folder_summary_count (folder->summary);
-	if (ifolder->exists_on_server == total) {
-		guint32 unread;
+
+	/* We don't have valid unread count or modseq for currently-selected server
+	   (unless we want to re-SELECT it). We fake unread count when fetching
+	   message flags, but don't depend on modseq for the selected folder */
+		if (total != ifolder->exists_on_server ||
+		    ifolder->last_known_uidnext != ifolder->uidnext_on_server ||
+		    folder->summary->unread_count != ifolder->unread_on_server ||
+		    (!is_selected && ifolder->last_known_modseq != ifolder->modseq_on_server))
+			need_rescan = TRUE;
+
+	/* If we don't think there's anything to do, poke it to check */
+	if (!need_rescan) {
 		CamelIMAPXCommand *ic;
 		
-		if (is->cinfo && is->cinfo->capa & IMAPX_CAPABILITY_CONDSTORE)
-			ic = camel_imapx_command_new ("STATUS", NULL, "STATUS %f (MESSAGES UNSEEN HIGHESTMODSEQ)", folder);
-		else
-			ic = camel_imapx_command_new ("STATUS", NULL, "STATUS %f (MESSAGES UNSEEN)", folder);
-		ic->job = job;
-		ic->pri = job->pri;
-		ic->complete = imapx_command_status_done;
-		imapx_command_run_sync (is, ic);
-
-		if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
-			if (!camel_exception_is_set (ic->ex))
-				camel_exception_setv(job->ex, 1, "Error refreshing folder: %s", ic->status->text);
+		if (is_selected) {
+			/* We may not issue STATUS on the current folder. Use SELECT or NOOP instead. */
+			if (0 /* server needs SELECT not just NOOP*/) {
+				if (imapx_idle_supported(is) && imapx_in_idle(is))
+					imapx_stop_idle(is, job->ex);
+				if (camel_exception_is_set(job->ex))
+					goto exception;
+				imapx_select(is, folder, TRUE, job->ex);
+				if (camel_exception_is_set(job->ex))
+					goto exception;
+			} else {
+				/* Or maybe just NOOP, unless we're in IDLE in which case do nothing */
+				if (!imapx_idle_supported(is) || !imapx_in_idle(is)) {
+					camel_imapx_server_noop(is, folder, job->ex);
+					if (camel_exception_is_set(job->ex))
+						goto exception;
+				}
+			}
+		} else {
+			if (is->cinfo && is->cinfo->capa & IMAPX_CAPABILITY_CONDSTORE)
+				ic = camel_imapx_command_new ("STATUS", NULL, "STATUS %f (MESSAGES UNSEEN UIDNEXT HIGHESTMODSEQ)", folder);
 			else
-				camel_exception_xfer (job->ex, ic->ex);
+				ic = camel_imapx_command_new ("STATUS", NULL, "STATUS %f (MESSAGES UNSEEN UIDNEXT)", folder);
+		
+			ic->job = job;
+			ic->pri = job->pri;
+			ic->complete = imapx_command_status_done;
 
+			imapx_command_run_sync (is, ic);
+
+			if (camel_exception_is_set (ic->ex) || ic->status->result != IMAPX_OK) {
+				if (!camel_exception_is_set (ic->ex))
+					camel_exception_setv(job->ex, 1, "Error refreshing folder: %s", ic->status->text);
+				else
+					camel_exception_xfer (job->ex, ic->ex);
+
+				camel_imapx_command_free (ic);
+				goto exception;
+			}
 			camel_imapx_command_free (ic);
-			goto exception;
 		}
-		camel_imapx_command_free (ic);
 
-		unread = folder->summary->unread_count;
+		/* Recalulate need_rescan */
+		if (total != ifolder->exists_on_server ||
+		    ifolder->last_known_uidnext != ifolder->uidnext_on_server ||
+		    folder->summary->unread_count != ifolder->unread_on_server ||
+		    (!is_selected && ifolder->last_known_modseq != ifolder->modseq_on_server))
+			need_rescan = TRUE;
 
-		e(printf("total %d / %d, unread %d / %d, modseq %d / %d\n",
-		       total, ifolder->exists_on_server,
-		       unread, ifolder->unread_on_server,
-			 ifolder->last_known_modseq, ifolder->modseq_on_server));
-		if (total == ifolder->exists_on_server &&
-		    unread == ifolder->unread_on_server &&
-		    ifolder->last_known_modseq == ifolder->modseq_on_server)
-			goto exception;
 	}
 
-	ifolder->last_known_modseq = ifolder->modseq_on_server;
-	imapx_job_scan_changes_start (is, job);
-	return;
+	e(printf("folder %s is %sselected, total %d / %d, unread %d / %d, modseq %d / %d, uidnext %d / %d: will %srescan\n",
+		 full_name, is_selected?"": "not ", total, ifolder->exists_on_server,
+		 folder->summary->unread_count, ifolder->unread_on_server,
+		 ifolder->last_known_modseq, ifolder->modseq_on_server,
+		 ifolder->last_known_uidnext, ifolder->uidnext_on_server,
+		 need_rescan?"":"not "));
+
+	/* The unread_on_server count is only valid for a non-selected folder
+	   where we used the STATUS command. For the selected folder we don't
+	   have an accurate current UNSEEN count */
+	if (need_rescan) {
+		imapx_job_scan_changes_start (is, job);
+		return;
+	}
 
 exception:
 	imapx_job_done (is, job);
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index e1f774f..323fa8b 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -99,6 +99,7 @@ struct _CamelIMAPXServer {
 	guint32 uidvalidity;
 	guint32 unseen;
 	guint32 highestmodseq;
+	guint32 uidnext;
 	guint32 exists;
 	guint32 recent;
 	guint32 mode;
diff --git a/camel/providers/imapx/camel-imapx-stream.c b/camel/providers/imapx/camel-imapx-stream.c
index c63cdc3..c2ced74 100644
--- a/camel/providers/imapx/camel-imapx-stream.c
+++ b/camel/providers/imapx/camel-imapx-stream.c
@@ -36,7 +36,7 @@
 #include "camel-imapx-exception.h"
 
 #define t(x) 
-#define io(x)
+#define io(x) x
 
 #define CAMEL_IMAPX_STREAM_SIZE (4096)
 #define CAMEL_IMAPX_STREAM_TOKEN (4096) /* maximum token size */
diff --git a/camel/providers/imapx/camel-imapx-tokenise.h b/camel/providers/imapx/camel-imapx-tokenise.h
index d7e6e82..b349104 100644
--- a/camel/providers/imapx/camel-imapx-tokenise.h
+++ b/camel/providers/imapx/camel-imapx-tokenise.h
@@ -32,12 +32,12 @@
 struct _imapx_keyword {const gchar *name; camel_imapx_id_t id; };
 struct _imapx_keyword *imapx_tokenise_struct (register const char *str, register unsigned int len);
 
-#define TOTAL_KEYWORDS 37
+#define TOTAL_KEYWORDS 39
 #define MIN_WORD_LENGTH 2
 #define MAX_WORD_LENGTH 14
 #define MIN_HASH_VALUE 5
-#define MAX_HASH_VALUE 56
-/* maximum key range = 52, duplicates = 0 */
+#define MAX_HASH_VALUE 63
+/* maximum key range = 59, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -51,32 +51,32 @@ imapx_hash (register const char *str, register unsigned int len)
 {
   static unsigned char asso_values[] =
     {
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 25, 15, 10, 20,  0,
-       5, 57,  5, 10, 57,  0, 30, 10, 25, 15,
-       0,  5,  0, 25, 10, 10, 57, 57, 57,  5,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57, 57, 57, 57, 57,
-      57, 57, 57, 57, 57, 57
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64,  0, 15, 25, 20,  0,
+       0, 64, 30,  0, 64,  0, 30, 30, 25, 15,
+       0, 10,  0, 25, 10, 10, 64, 64, 64,  5,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64, 64, 64, 64, 64, 64
     };
   return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
 }
@@ -105,14 +105,14 @@ imapx_tokenise_struct (register const char *str, register unsigned int len)
       {"READ-WRITE",	IMAPX_READ_WRITE},
 #line 34 "camel-imapx-tokens.txt"
       {"RFC822.SIZE",	IMAPX_RFC822_SIZE},
-#line 29 "camel-imapx-tokens.txt"
-      {"PREAUTH",	IMAPX_PREAUTH},
+#line 19 "camel-imapx-tokens.txt"
+      {"INTERNALDATE",	IMAPX_INTERNALDATE},
 #line 33 "camel-imapx-tokens.txt"
       {"RFC822.HEADER",	IMAPX_RFC822_HEADER},
 #line 30 "camel-imapx-tokens.txt"
       {"READ-ONLY",	IMAPX_READ_ONLY},
-#line 17 "camel-imapx-tokens.txt"
-      {"FETCH",		IMAPX_FETCH},
+#line 6 "camel-imapx-tokens.txt"
+      {"ALERT",          IMAPX_ALERT},
 #line 32 "camel-imapx-tokens.txt"
       {"RECENT",		IMAPX_RECENT},
 #line 26 "camel-imapx-tokens.txt"
@@ -124,21 +124,20 @@ imapx_tokenise_struct (register const char *str, register unsigned int len)
       {""},
 #line 35 "camel-imapx-tokens.txt"
       {"RFC822.TEXT",	IMAPX_RFC822_TEXT},
-#line 19 "camel-imapx-tokens.txt"
-      {"INTERNALDATE",	IMAPX_INTERNALDATE},
-#line 42 "camel-imapx-tokens.txt"
-      {"HIGHESTMODSEQ",	IMAPX_HIGHESTMODSEQ},
+      {""}, {""},
 #line 9 "camel-imapx-tokens.txt"
       {"BODY",		IMAPX_BODY},
-#line 12 "camel-imapx-tokens.txt"
-      {"CAPABILITY",	IMAPX_CAPABILITY},
+      {""},
 #line 39 "camel-imapx-tokens.txt"
       {"UIDVALIDITY",	IMAPX_UIDVALIDITY},
 #line 41 "camel-imapx-tokens.txt"
       {"UIDNEXT",	IMAPX_UIDNEXT},
 #line 10 "camel-imapx-tokens.txt"
       {"BODYSTRUCTURE",	IMAPX_BODYSTRUCTURE},
-      {""}, {""},
+#line 7 "camel-imapx-tokens.txt"
+      {"APPENDUID",	IMAPX_APPENDUID},
+#line 18 "camel-imapx-tokens.txt"
+      {"FLAGS",		IMAPX_FLAGS},
 #line 15 "camel-imapx-tokens.txt"
       {"EXISTS",		IMAPX_EXISTS},
 #line 24 "camel-imapx-tokens.txt"
@@ -147,34 +146,42 @@ imapx_tokenise_struct (register const char *str, register unsigned int len)
       {"UID",		IMAPX_UID},
 #line 23 "camel-imapx-tokens.txt"
       {"NAMESPACE",	IMAPX_NAMESPACE},
-#line 18 "camel-imapx-tokens.txt"
-      {"FLAGS",		IMAPX_FLAGS},
+#line 17 "camel-imapx-tokens.txt"
+      {"FETCH",		IMAPX_FETCH},
       {""},
-#line 13 "camel-imapx-tokens.txt"
-      {"COPYUID",	IMAPX_COPYUID},
+#line 29 "camel-imapx-tokens.txt"
+      {"PREAUTH",	IMAPX_PREAUTH},
 #line 8 "camel-imapx-tokens.txt"
       {"BAD",		IMAPX_BAD},
 #line 28 "camel-imapx-tokens.txt"
       {"PERMANENTFLAGS",	IMAPX_PERMANENTFLAGS},
-#line 6 "camel-imapx-tokens.txt"
-      {"ALERT",          IMAPX_ALERT},
+#line 12 "camel-imapx-tokens.txt"
+      {"CAPABILITY",	IMAPX_CAPABILITY},
 #line 40 "camel-imapx-tokens.txt"
       {"UNSEEN",		IMAPX_UNSEEN},
 #line 25 "camel-imapx-tokens.txt"
       {"NO",		IMAPX_NO},
-#line 22 "camel-imapx-tokens.txt"
-      {"MESSAGES",	IMAPX_MESSAGES},
+#line 43 "camel-imapx-tokens.txt"
+      {"NOMODSEQ",	IMAPX_NOMODSEQ},
 #line 20 "camel-imapx-tokens.txt"
       {"LIST",		IMAPX_LIST},
-      {""}, {""}, {""}, {""},
+      {""},
+#line 44 "camel-imapx-tokens.txt"
+      {"MODSEQ",		IMAPX_MODSEQ},
+      {""}, {""},
 #line 21 "camel-imapx-tokens.txt"
       {"LSUB",		IMAPX_LSUB},
-      {""}, {""}, {""}, {""},
-#line 7 "camel-imapx-tokens.txt"
-      {"APPENDUID",	IMAPX_APPENDUID},
-      {""},
+      {""}, {""},
+#line 13 "camel-imapx-tokens.txt"
+      {"COPYUID",	IMAPX_COPYUID},
+#line 42 "camel-imapx-tokens.txt"
+      {"HIGHESTMODSEQ",	IMAPX_HIGHESTMODSEQ},
+      {""}, {""},
 #line 36 "camel-imapx-tokens.txt"
-      {"STATUS",		IMAPX_STATUS}
+      {"STATUS",		IMAPX_STATUS},
+      {""}, {""}, {""}, {""}, {""}, {""},
+#line 22 "camel-imapx-tokens.txt"
+      {"MESSAGES",	IMAPX_MESSAGES}
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/camel/providers/imapx/camel-imapx-tokens.txt b/camel/providers/imapx/camel-imapx-tokens.txt
index e7d6e98..eb39fd0 100644
--- a/camel/providers/imapx/camel-imapx-tokens.txt
+++ b/camel/providers/imapx/camel-imapx-tokens.txt
@@ -40,3 +40,5 @@ UIDVALIDITY,	IMAPX_UIDVALIDITY
 UNSEEN,		IMAPX_UNSEEN
 UIDNEXT,	IMAPX_UIDNEXT
 HIGHESTMODSEQ,	IMAPX_HIGHESTMODSEQ
+NOMODSEQ,	IMAPX_NOMODSEQ
+MODSEQ,		IMAPX_MODSEQ
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index bbd49ec..fdbde33 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -1288,6 +1288,32 @@ imapx_parse_section(CamelIMAPXStream *is, CamelException *ex)
 	return section;
 }
 
+static guint
+imapx_parse_modseq(CamelIMAPXStream *is, CamelException *ex)
+{
+	guint ret;
+	gint tok;
+	guint len;
+	guchar *token;
+
+	
+	tok = camel_imapx_stream_token(is, &token, &len, ex);
+	if (tok != '(') {
+		camel_exception_set (ex, 1, "fetch: expecting '('");
+		return 0;
+	}
+	ret = camel_imapx_stream_number(is, ex);
+	if (camel_exception_is_set(ex))
+		return 0;
+
+	tok = camel_imapx_stream_token(is, &token, &len, ex);
+	if (tok != ')') {
+		camel_exception_set (ex, 1, "fetch: expecting '('");
+		return 0;
+	}
+	return ret;
+}
+
 void
 imapx_free_fetch(struct _fetch_info *finfo)
 {
@@ -1418,6 +1444,10 @@ imapx_parse_fetch(CamelIMAPXStream *is, CamelException *ex)
 				finfo->cinfo = imapx_parse_body(is, ex);
 				finfo->got |= FETCH_CINFO;
 				break;
+			case IMAPX_MODSEQ:
+				finfo->modseq = imapx_parse_modseq(is, ex);
+				finfo->got |= FETCH_MODSEQ;
+				break;
 			case IMAPX_BODY:
 				tok = camel_imapx_stream_token(is, &token, &len, ex);
 				camel_imapx_stream_ungettoken(is, tok, token, len);
@@ -1506,6 +1536,8 @@ imapx_parse_status_info (struct _CamelIMAPXStream *is, CamelException *ex)
 			case IMAPX_HIGHESTMODSEQ:
 				sinfo->highestmodseq = camel_imapx_stream_number (is, ex);
 				break;
+			case IMAPX_NOMODSEQ:
+			break;
 			default:
 				g_free (sinfo);
 				camel_exception_set (ex, 1, "unknown status response");
diff --git a/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h
index 3cc2fab..fb6bb25 100644
--- a/camel/providers/imapx/camel-imapx-utils.h
+++ b/camel/providers/imapx/camel-imapx-utils.h
@@ -50,6 +50,8 @@ typedef enum _camel_imapx_id_t {
 	IMAPX_UNSEEN,
 	IMAPX_UIDNEXT,
 	IMAPX_HIGHESTMODSEQ,
+	IMAPX_NOMODSEQ,
+	IMAPX_MODSEQ,
 } camel_imapx_id_t;
 
 /* str MUST be in upper case, tokenised using gperf function */
@@ -114,6 +116,7 @@ struct _fetch_info {
 	guint32 size;		/* RFC822.SIZE */
 	guint32 offset;		/* start offset of a BODY[]<offset.length> request */
 	guint32 flags;		/* FLAGS */
+	guint32 modseq;		/* MODSEQ */
 	struct _CamelFlag *user_flags;
 	gchar *date;		/* INTERNALDATE */
 	gchar *section;		/* section for a BODY[section] request */
@@ -131,6 +134,7 @@ struct _fetch_info {
 #define FETCH_DATE (1<<8)
 #define FETCH_SECTION (1<<9)
 #define FETCH_UID (1<<10)
+#define FETCH_MODSEQ (1<<11)
 
 struct _fetch_info *imapx_parse_fetch(struct _CamelIMAPXStream *is, CamelException *ex);
 void imapx_free_fetch(struct _fetch_info *finfo);
