Index: camel/providers/imap/camel-imap-store.c
===================================================================
--- camel/providers/imap/camel-imap-store.c	(revision 10154)
+++ camel/providers/imap/camel-imap-store.c	(working copy)
@@ -3039,7 +3039,8 @@ camel_imap_store_readline (CamelImapStor
 			camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 					      _("Server unexpectedly disconnected: %s"),
 					      g_strerror (errno));
-		
+
+		printf ("%s: disconnect\n", __FUNCTION__);		
 		camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
 		g_byte_array_free (ba, TRUE);
 		return -1;
Index: camel/providers/imap/camel-imap-command.c
===================================================================
--- camel/providers/imap/camel-imap-command.c	(revision 10154)
+++ camel/providers/imap/camel-imap-command.c	(working copy)
@@ -179,6 +179,12 @@ imap_command_start (CamelImapStore *stor
 {
 	ssize_t nwritten;
 
+	if (!store->ostream || !store->istream)
+		printf ("%s: not connected probably...\n", __FUNCTION__);
+
+	if (!camel_imap_store_connected (store, ex))
+		return FALSE;
+
 	if (!store->ostream) {
 		camel_exception_set (ex, CAMEL_EXCEPTION_STORE_INVALID, _("No output stream"));
 		return FALSE;
@@ -233,6 +239,7 @@ imap_command_start (CamelImapStore *stor
 			camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 					     g_strerror (errno));
 		
+		printf ("%s: disconnect\n", __FUNCTION__);
 		camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
 		return FALSE;
 	}
@@ -260,17 +267,16 @@ CamelImapResponse *
 camel_imap_command_continuation (CamelImapStore *store, const char *cmd,
 				 size_t cmdlen, CamelException *ex)
 {
-	if (!camel_imap_store_connected (store, ex))
-		return NULL;
-
 	if (!store->ostream) {
+		printf ("%s: oops\n", __FUNCTION__);
 		camel_exception_set (ex, CAMEL_EXCEPTION_STORE_INVALID, _("No output stream"));
-		return FALSE;
+		return NULL;
 	}
 
 	if (!store->istream) {
+		printf ("%s: oops2\n", __FUNCTION__);
 		camel_exception_set (ex, CAMEL_EXCEPTION_STORE_INVALID, _("No input stream"));
-		return FALSE;
+		return NULL;
 	}
 
 	if (camel_stream_write (store->ostream, cmd, cmdlen) == -1 ||
@@ -281,6 +287,7 @@ camel_imap_command_continuation (CamelIm
 		else
 			camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 					     g_strerror (errno));
+		printf ("%s: disconnect\n", __FUNCTION__);
 		camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
 		CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
 		return NULL;
@@ -495,6 +502,7 @@ imap_read_untagged (CamelImapStore *stor
 				else
 					camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 							     g_strerror (errno));
+				printf ("%s: disconnect\n", __FUNCTION__);
 				camel_service_disconnect (CAMEL_SERVICE (store), FALSE, NULL);
 				g_string_free (str, TRUE);
 				goto lose;
