[evolution-data-server] Merge some cleanup bits from camel-gobject.



commit ac0da7deb1c2ddbca37738005353466be848d9f0
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Apr 12 20:56:27 2010 -0400

    Merge some cleanup bits from camel-gobject.

 camel/camel-cipher-context.c                       |    3 +-
 camel/camel-data-cache.c                           |    2 +-
 camel/camel-data-wrapper.c                         |    4 +-
 camel/camel-disco-folder.c                         |    5 +-
 camel/camel-disco-store.c                          |    9 +-
 camel/camel-filter-driver.c                        |  323 +++---
 camel/camel-filter-search.c                        |   36 +-
 camel/camel-folder-search.c                        |  244 +++--
 camel/camel-folder-search.h                        |    2 +
 camel/camel-folder-summary.c                       |  272 ++---
 camel/camel-folder-summary.h                       |   10 +-
 camel/camel-folder-thread.c                        |    3 +-
 camel/camel-folder.c                               |  746 ++++++------
 camel/camel-folder.h                               |    2 +
 camel/camel-gpg-context.c                          |   20 +-
 camel/camel-http-stream.c                          |    5 +-
 camel/camel-index-control.c                        |    2 +-
 camel/camel-index.c                                |  248 +++--
 camel/camel-index.h                                |    6 +
 camel/camel-mime-message.c                         |    6 +-
 camel/camel-mime-parser.c                          |   74 +-
 camel/camel-mime-part-utils.c                      |    9 +-
 camel/camel-mime-part.c                            | 1075 +++++++++--------
 camel/camel-mime-part.h                            |   16 +-
 camel/camel-mime-utils.c                           |   16 +-
 camel/camel-multipart-encrypted.c                  |  101 +-
 camel/camel-multipart-signed.c                     |  562 +++++-----
 camel/camel-multipart-signed.h                     |    1 -
 camel/camel-multipart.c                            |  688 ++++++------
 camel/camel-multipart.h                            |    2 +
 camel/camel-object.c                               |   12 +-
 camel/camel-object.h                               |    9 +-
 camel/camel-offline-folder.c                       |  146 ++--
 camel/camel-offline-folder.h                       |    2 +
 camel/camel-offline-journal.c                      |   68 +-
 camel/camel-offline-store.c                        |   92 +-
 camel/camel-partition-table.c                      |   14 +-
 camel/camel-sasl.c                                 |    3 +-
 camel/camel-seekable-substream.c                   |    3 +-
 camel/camel-service.c                              |    3 +-
 camel/camel-session.c                              |    3 +-
 camel/camel-smime-context.c                        |    2 +-
 camel/camel-store-summary.c                        |  454 ++++----
 camel/camel-store.c                                |   20 +-
 camel/camel-stream-buffer.c                        |    3 +-
 camel/camel-stream-filter.c                        |    6 +-
 camel/camel-tcp-stream-ssl.c                       |    6 +-
 camel/camel-text-index.c                           | 1163 ++++++++++----------
 camel/camel-vee-folder.c                           | 1207 ++++++++++----------
 camel/camel-vee-store.c                            |  523 +++++-----
 camel/camel-vee-summary.c                          |   53 +-
 camel/camel-vee-summary.h                          |    1 -
 camel/camel-vtrash-folder.c                        |  197 ++--
 camel/providers/groupwise/camel-groupwise-folder.c |    3 +-
 camel/providers/groupwise/camel-groupwise-store.c  |    6 +-
 .../providers/groupwise/camel-groupwise-summary.c  |    6 +-
 camel/providers/groupwise/camel-groupwise-utils.c  |    6 +-
 camel/providers/imap/camel-imap-command.c          |    4 +-
 camel/providers/imap/camel-imap-folder.c           |    8 +-
 camel/providers/imap/camel-imap-search.c           |    6 +-
 camel/providers/imap/camel-imap-store.c            |   22 +-
 camel/providers/imap/camel-imap-summary.c          |    8 +-
 camel/providers/imap/camel-imap-wrapper.c          |    6 +-
 camel/providers/imapx/camel-imapx-folder.c         |    4 +-
 camel/providers/imapx/camel-imapx-server.c         |   52 +-
 camel/providers/imapx/camel-imapx-store.c          |    6 +-
 camel/providers/imapx/camel-imapx-stream.c         |    6 +-
 camel/providers/imapx/camel-imapx-summary.c        |    8 +-
 camel/providers/imapx/camel-imapx-utils.c          |    8 +-
 camel/providers/local/camel-local-folder.c         |    6 +-
 camel/providers/local/camel-local-store.c          |    4 +-
 camel/providers/local/camel-local-summary.c        |   13 +-
 camel/providers/local/camel-maildir-folder.c       |    4 +-
 camel/providers/local/camel-maildir-store.c        |    4 +-
 camel/providers/local/camel-maildir-summary.c      |    7 +-
 camel/providers/local/camel-mbox-folder.c          |    6 +-
 camel/providers/local/camel-mbox-store.c           |   12 +-
 camel/providers/local/camel-mbox-summary.c         |   17 +-
 camel/providers/local/camel-mh-folder.c            |    4 +-
 camel/providers/local/camel-mh-store.c             |   14 +-
 camel/providers/local/camel-mh-summary.c           |    2 +-
 camel/providers/local/camel-spool-store.c          |    4 +-
 camel/providers/nntp/camel-nntp-folder.c           |    5 +-
 camel/providers/nntp/camel-nntp-store.c            |    4 +-
 camel/providers/nntp/camel-nntp-stream.c           |    5 +-
 camel/providers/nntp/camel-nntp-summary.c          |    8 +-
 camel/providers/pop3/camel-pop3-engine.c           |    2 +-
 camel/providers/pop3/camel-pop3-folder.c           |   17 +-
 camel/providers/pop3/camel-pop3-store.c            |   10 +-
 camel/providers/pop3/camel-pop3-stream.c           |    5 +-
 camel/tests/folder/test1.c                         |    2 +-
 camel/tests/folder/test10.c                        |   10 +-
 camel/tests/folder/test4.c                         |    2 +-
 camel/tests/folder/test5.c                         |    2 +-
 camel/tests/folder/test8.c                         |    2 +-
 camel/tests/folder/test9.c                         |    3 +-
 camel/tests/lib/camel-test.h                       |    2 +-
 camel/tests/lib/folders.c                          |    2 +-
 camel/tests/lib/messages.c                         |    4 +-
 camel/tests/smime/pgp.c                            |   22 +-
 .../reference/camel/tmpl/camel-folder-summary.sgml |    2 -
 docs/reference/camel/tmpl/camel-mime-part.sgml     |    8 +-
 docs/reference/camel/tmpl/camel-object.sgml        |    1 +
 docs/reference/camel/tmpl/camel-stream-buffer.sgml |   10 +-
 docs/reference/camel/tmpl/camel-stream-filter.sgml |    1 -
 docs/reference/camel/tmpl/camel-stream-fs.sgml     |    2 +-
 docs/reference/camel/tmpl/camel-stream-mem.sgml    |    4 +-
 107 files changed, 4489 insertions(+), 4384 deletions(-)
---
diff --git a/camel/camel-cipher-context.c b/camel/camel-cipher-context.c
index d7cf726..c0cfba3 100644
--- a/camel/camel-cipher-context.c
+++ b/camel/camel-cipher-context.c
@@ -631,8 +631,7 @@ cipher_context_set_session (CamelCipherContext *context,
 	g_return_if_fail (CAMEL_IS_SESSION (session));
 	g_return_if_fail (context->priv->session == NULL);
 
-	context->priv->session = session;
-	camel_object_ref (session);
+	context->priv->session = camel_object_ref (session);
 }
 
 static void
diff --git a/camel/camel-data-cache.c b/camel/camel-data-cache.c
index 7d18d09..60cd7d6 100644
--- a/camel/camel-data-cache.c
+++ b/camel/camel-data-cache.c
@@ -314,7 +314,7 @@ camel_data_cache_add(CamelDataCache *cdc, const gchar *path, const gchar *key, C
 		if (stream) {
 			g_unlink(real);
 			camel_object_bag_remove(cdc->priv->busy_bag, stream);
-			camel_object_unref(stream);
+			camel_object_unref (stream);
 		}
 	} while (stream != NULL);
 
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index a4f305a..c739375 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -159,8 +159,8 @@ data_wrapper_construct_from_stream (CamelDataWrapper *data_wrapper,
 	if (data_wrapper->stream)
 		camel_object_unref (data_wrapper->stream);
 
-	data_wrapper->stream = stream;
-	camel_object_ref (stream);
+	data_wrapper->stream = camel_object_ref (stream);
+
 	return 0;
 }
 
diff --git a/camel/camel-disco-folder.c b/camel/camel-disco-folder.c
index b734115..9ed5502 100644
--- a/camel/camel-disco-folder.c
+++ b/camel/camel-disco-folder.c
@@ -129,7 +129,7 @@ cdf_sync_free(CamelSession *session, CamelSessionThreadMsg *mm)
 
 	if (m->changes)
 		camel_folder_change_info_free(m->changes);
-	camel_object_unref(m->folder);
+	camel_object_unref (m->folder);
 }
 
 static CamelSessionThreadOps cdf_sync_ops = {
@@ -149,8 +149,7 @@ cdf_folder_changed(CamelFolder *folder, CamelFolderChangeInfo *changes, gpointer
 		m = camel_session_thread_msg_new(session, &cdf_sync_ops, sizeof(*m));
 		m->changes = camel_folder_change_info_new();
 		camel_folder_change_info_cat(m->changes, changes);
-		m->folder = folder;
-		camel_object_ref(folder);
+		m->folder = camel_object_ref (folder);
 		camel_session_thread_queue(session, &m->msg, 0);
 	}
 }
diff --git a/camel/camel-disco-store.c b/camel/camel-disco-store.c
index 0771bde..8b49c54 100644
--- a/camel/camel-disco-store.c
+++ b/camel/camel-disco-store.c
@@ -171,10 +171,9 @@ disco_connect (CamelService *service, CamelException *ex)
 		/* Need to resync.  Note we do the ref thing since during the replay
 		   disconnect could be called, which will remove store->diary and unref it */
 		store->status = CAMEL_DISCO_STORE_RESYNCING;
-		diary = store->diary;
-		camel_object_ref(diary);
+		diary = camel_object_ref (store->diary);
 		camel_disco_diary_replay(diary, ex);
-		camel_object_unref(diary);
+		camel_object_unref (diary);
 		store->status = CAMEL_DISCO_STORE_ONLINE;
 		if (camel_exception_is_set (ex))
 			return FALSE;
@@ -324,7 +323,7 @@ set_status(CamelDiscoStore *disco_store, CamelDiscoStoreStatus status, CamelExce
 						camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder, "", &x);
 						camel_exception_clear(&x);
 					}
-					camel_object_unref(folder);
+					camel_object_unref (folder);
 				}
 				g_ptr_array_free(folders, TRUE);
 			}
@@ -432,7 +431,7 @@ camel_disco_store_prepare_for_offline(CamelDiscoStore *disco_store, CamelExcepti
 						camel_disco_folder_prepare_for_offline((CamelDiscoFolder *)folder, "(match-all)", &x);
 						camel_exception_clear(&x);
 					}
-					camel_object_unref(folder);
+					camel_object_unref (folder);
 				}
 				g_ptr_array_free(folders, TRUE);
 			}
diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c
index 863ff63..2320151 100644
--- a/camel/camel-filter-driver.c
+++ b/camel/camel-filter-driver.c
@@ -31,7 +31,6 @@
 #include <sys/types.h>
 #include <time.h>
 
-#include <glib.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
 
@@ -125,11 +124,7 @@ struct _CamelFilterDriverPrivate {
 	ESExp *eval;
 };
 
-#define _PRIVATE(o) (((CamelFilterDriver *)(o))->priv)
-
-static void camel_filter_driver_class_init (CamelFilterDriverClass *klass);
-static void camel_filter_driver_init       (CamelFilterDriver *obj);
-static void camel_filter_driver_finalize   (CamelObject *obj);
+#define CAMEL_FILTER_DRIVER_GET_PRIVATE(o) (((CamelFilterDriver *)(o))->priv)
 
 static void camel_filter_driver_log (CamelFilterDriver *driver, enum filter_log_t status, const gchar *desc, ...);
 
@@ -180,30 +175,52 @@ static struct {
 
 static CamelObjectClass *camel_filter_driver_parent;
 
-CamelType
-camel_filter_driver_get_type (void)
+static void
+free_hash_strings (gpointer key, gpointer value, gpointer data)
 {
-	static CamelType type = CAMEL_INVALID_TYPE;
+	g_free (key);
+	g_free (value);
+}
 
-	if (type == CAMEL_INVALID_TYPE)	{
-		type = camel_type_register (CAMEL_TYPE_OBJECT,
-					    "CamelFilterDriver",
-					    sizeof (CamelFilterDriver),
-					    sizeof (CamelFilterDriverClass),
-					    (CamelObjectClassInitFunc) camel_filter_driver_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_filter_driver_init,
-					    (CamelObjectFinalizeFunc) camel_filter_driver_finalize);
+static void
+camel_filter_driver_finalize (CamelObject *obj)
+{
+	CamelFilterDriver *driver = (CamelFilterDriver *) obj;
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
+	struct _filter_rule *node;
+
+	/* close all folders that were opened for appending */
+	close_folders (driver);
+	g_hash_table_destroy (p->folders);
+
+	g_hash_table_foreach (p->globals, free_hash_strings, driver);
+	g_hash_table_destroy (p->globals);
+
+	g_hash_table_foreach (p->only_once, free_hash_strings, driver);
+	g_hash_table_destroy (p->only_once);
+
+	e_sexp_unref(p->eval);
+
+	if (p->defaultfolder) {
+		camel_folder_thaw (p->defaultfolder);
+		camel_object_unref (p->defaultfolder);
 	}
 
-	return type;
+	while ((node = (struct _filter_rule *)camel_dlist_remhead(&p->rules))) {
+		g_free(node->match);
+		g_free(node->action);
+		g_free(node->name);
+		g_free(node);
+	}
+
+	camel_object_unref (p->session);
+
+	g_free (p);
 }
 
 static void
 camel_filter_driver_class_init (CamelFilterDriverClass *klass)
 {
-	/*CamelObjectClass *object_class = (CamelObjectClass *) klass;*/
-
 	camel_filter_driver_parent = camel_type_get_global_classfuncs(camel_object_get_type());
 }
 
@@ -213,7 +230,7 @@ camel_filter_driver_init (CamelFilterDriver *obj)
 	struct _CamelFilterDriverPrivate *p;
 	gint i;
 
-	p = _PRIVATE (obj) = g_malloc0 (sizeof (*p));
+	p = CAMEL_FILTER_DRIVER_GET_PRIVATE (obj) = g_malloc0 (sizeof (*p));
 
 	camel_dlist_init(&p->rules);
 
@@ -234,47 +251,23 @@ camel_filter_driver_init (CamelFilterDriver *obj)
 	p->only_once = g_hash_table_new (g_str_hash, g_str_equal);
 }
 
-static void
-free_hash_strings (gpointer key, gpointer value, gpointer data)
-{
-	g_free (key);
-	g_free (value);
-}
-
-static void
-camel_filter_driver_finalize (CamelObject *obj)
+CamelType
+camel_filter_driver_get_type (void)
 {
-	CamelFilterDriver *driver = (CamelFilterDriver *) obj;
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
-	struct _filter_rule *node;
-
-	/* close all folders that were opened for appending */
-	close_folders (driver);
-	g_hash_table_destroy (p->folders);
-
-	g_hash_table_foreach (p->globals, free_hash_strings, driver);
-	g_hash_table_destroy (p->globals);
-
-	g_hash_table_foreach (p->only_once, free_hash_strings, driver);
-	g_hash_table_destroy (p->only_once);
-
-	e_sexp_unref(p->eval);
-
-	if (p->defaultfolder) {
-		camel_folder_thaw (p->defaultfolder);
-		camel_object_unref (p->defaultfolder);
-	}
+	static CamelType type = CAMEL_INVALID_TYPE;
 
-	while ((node = (struct _filter_rule *)camel_dlist_remhead(&p->rules))) {
-		g_free(node->match);
-		g_free(node->action);
-		g_free(node->name);
-		g_free(node);
+	if (type == CAMEL_INVALID_TYPE)	{
+		type = camel_type_register (CAMEL_TYPE_OBJECT,
+					    "CamelFilterDriver",
+					    sizeof (CamelFilterDriver),
+					    sizeof (CamelFilterDriverClass),
+					    (CamelObjectClassInitFunc) camel_filter_driver_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_filter_driver_init,
+					    (CamelObjectFinalizeFunc) camel_filter_driver_finalize);
 	}
 
-	camel_object_unref(p->session);
-
-	g_free (p);
+	return type;
 }
 
 /**
@@ -285,10 +278,10 @@ camel_filter_driver_finalize (CamelObject *obj)
 CamelFilterDriver *
 camel_filter_driver_new (CamelSession *session)
 {
-	CamelFilterDriver *d = (CamelFilterDriver *)camel_object_new(camel_filter_driver_get_type());
+	CamelFilterDriver *d;
 
-	d->priv->session = session;
-	camel_object_ref((CamelObject *)session);
+	d = (CamelFilterDriver *)camel_object_new(camel_filter_driver_get_type());
+	d->priv->session = camel_object_ref (session);
 
 	return d;
 }
@@ -296,7 +289,7 @@ camel_filter_driver_new (CamelSession *session)
 void
 camel_filter_driver_set_folder_func (CamelFilterDriver *d, CamelFilterGetFolderFunc get_folder, gpointer data)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 
 	p->get_folder = get_folder;
 	p->data = data;
@@ -305,7 +298,7 @@ camel_filter_driver_set_folder_func (CamelFilterDriver *d, CamelFilterGetFolderF
 void
 camel_filter_driver_set_logfile (CamelFilterDriver *d, FILE *logfile)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 
 	p->logfile = logfile;
 }
@@ -313,7 +306,7 @@ camel_filter_driver_set_logfile (CamelFilterDriver *d, FILE *logfile)
 void
 camel_filter_driver_set_status_func (CamelFilterDriver *d, CamelFilterStatusFunc *func, gpointer data)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 
 	p->statusfunc = func;
 	p->statusdata = data;
@@ -322,7 +315,7 @@ camel_filter_driver_set_status_func (CamelFilterDriver *d, CamelFilterStatusFunc
 void
 camel_filter_driver_set_shell_func (CamelFilterDriver *d, CamelFilterShellFunc *func, gpointer data)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 
 	p->shellfunc = func;
 	p->shelldata = data;
@@ -331,7 +324,7 @@ camel_filter_driver_set_shell_func (CamelFilterDriver *d, CamelFilterShellFunc *
 void
 camel_filter_driver_set_play_sound_func (CamelFilterDriver *d, CamelFilterPlaySoundFunc *func, gpointer data)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 
 	p->playfunc = func;
 	p->playdata = data;
@@ -340,7 +333,7 @@ camel_filter_driver_set_play_sound_func (CamelFilterDriver *d, CamelFilterPlaySo
 void
 camel_filter_driver_set_system_beep_func (CamelFilterDriver *d, CamelFilterSystemBeepFunc *func, gpointer data)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 
 	p->beep = func;
 	p->beepdata = data;
@@ -349,7 +342,7 @@ camel_filter_driver_set_system_beep_func (CamelFilterDriver *d, CamelFilterSyste
 void
 camel_filter_driver_set_default_folder (CamelFilterDriver *d, CamelFolder *def)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 
 	if (p->defaultfolder) {
 		camel_folder_thaw (p->defaultfolder);
@@ -367,7 +360,7 @@ camel_filter_driver_set_default_folder (CamelFilterDriver *d, CamelFolder *def)
 void
 camel_filter_driver_add_rule(CamelFilterDriver *d, const gchar *name, const gchar *match, const gchar *action)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 	struct _filter_rule *node;
 
 	node = g_malloc(sizeof(*node));
@@ -380,7 +373,7 @@ camel_filter_driver_add_rule(CamelFilterDriver *d, const gchar *name, const gcha
 gint
 camel_filter_driver_remove_rule_by_name (CamelFilterDriver *d, const gchar *name)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 	struct _filter_rule *node;
 
 	node = (struct _filter_rule *) p->rules.head;
@@ -405,7 +398,7 @@ static void
 report_status (CamelFilterDriver *driver, enum camel_filter_status_t status, gint pc, const gchar *desc, ...)
 {
 	/* call user-defined status report function */
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	va_list ap;
 	gchar *str;
 
@@ -421,7 +414,7 @@ report_status (CamelFilterDriver *driver, enum camel_filter_status_t status, gin
 void
 camel_filter_driver_set_global (CamelFilterDriver *d, const gchar *name, const gchar *value)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (d);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (d);
 	gchar *oldkey, *oldvalue;
 
 	if (g_hash_table_lookup_extended (p->globals, name, (gpointer)&oldkey, (gpointer)&oldvalue)) {
@@ -436,7 +429,7 @@ camel_filter_driver_set_global (CamelFilterDriver *d, const gchar *name, const g
 static ESExpResult *
 do_delete (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	d(fprintf (stderr, "doing delete\n"));
 	p->deleted = TRUE;
@@ -448,7 +441,7 @@ do_delete (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterD
 static ESExpResult *
 do_forward_to (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	d(fprintf (stderr, "marking message for forwarding\n"));
 
@@ -471,7 +464,7 @@ do_forward_to (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFil
 static ESExpResult *
 do_copy (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	gint i;
 
 	d(fprintf (stderr, "copying message...\n"));
@@ -520,7 +513,7 @@ do_copy (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDri
 static ESExpResult *
 do_move (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	gint i;
 
 	d(fprintf (stderr, "moving message...\n"));
@@ -583,7 +576,7 @@ do_move (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDri
 static ESExpResult *
 do_stop (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Stopped processing");
 	d(fprintf (stderr, "terminating message processing\n"));
@@ -595,7 +588,7 @@ do_stop (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDri
 static ESExpResult *
 do_label (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	d(fprintf (stderr, "setting label tag\n"));
 	if (argc > 0 && argv[0]->type == ESEXP_RES_STRING) {
@@ -627,7 +620,7 @@ do_label (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDr
 static ESExpResult *
 do_color (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	d(fprintf (stderr, "setting color tag\n"));
 	if (argc > 0 && argv[0]->type == ESEXP_RES_STRING) {
@@ -644,7 +637,7 @@ do_color (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDr
 static ESExpResult *
 do_score (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	d(fprintf (stderr, "setting score tag\n"));
 	if (argc > 0 && argv[0]->type == ESEXP_RES_INT) {
@@ -662,7 +655,7 @@ do_score (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDr
 static ESExpResult *
 do_adjust_score(struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE(driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE(driver);
 
 	d(fprintf (stderr, "adjusting score tag\n"));
 	if (argc > 0 && argv[0]->type == ESEXP_RES_INT) {
@@ -683,7 +676,7 @@ do_adjust_score(struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFi
 static ESExpResult *
 set_flag (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	guint32 flags;
 
 	d(fprintf (stderr, "setting flag\n"));
@@ -702,7 +695,7 @@ set_flag (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDr
 static ESExpResult *
 unset_flag (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	guint32 flags;
 
 	d(fprintf (stderr, "unsetting flag\n"));
@@ -750,7 +743,7 @@ child_watch (GPid     pid,
 static gint
 pipe_to_system (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	gint i, pipe_to_child, pipe_from_child;
 	CamelMimeMessage *message = NULL;
 	CamelMimeParser *parser;
@@ -791,9 +784,10 @@ pipe_to_system (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFi
 				       &error)) {
 		g_ptr_array_free (args, TRUE);
 
-		camel_exception_setv (p->ex, CAMEL_EXCEPTION_SYSTEM,
-				      _("Failed to create child process '%s': %s"),
-				      argv[0]->value.string, error->message);
+		camel_exception_setv (
+			p->ex, CAMEL_EXCEPTION_SYSTEM,
+			_("Failed to create child process '%s': %s"),
+			argv[0]->value.string, error->message);
 		g_error_free (error);
 		return -1;
 	}
@@ -833,10 +827,11 @@ pipe_to_system (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFi
 
 	message = camel_mime_message_new ();
 	if (camel_mime_part_construct_from_parser ((CamelMimePart *) message, parser) == -1) {
-		camel_exception_setv (p->ex, CAMEL_EXCEPTION_SYSTEM,
-				     _("Invalid message stream received from %s: %s"),
-				      argv[0]->value.string,
-				      g_strerror (camel_mime_parser_errno (parser)));
+		camel_exception_setv (
+			p->ex, CAMEL_EXCEPTION_SYSTEM,
+			_("Invalid message stream received from %s: %s"),
+			argv[0]->value.string,
+			g_strerror (camel_mime_parser_errno (parser)));
 		camel_object_unref (message);
 		message = NULL;
 	} else {
@@ -890,7 +885,7 @@ pipe_message (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilt
 static ESExpResult *
 do_shell (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	GString *command;
 	GPtrArray *args;
 	gint i;
@@ -931,7 +926,7 @@ do_shell (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDr
 static ESExpResult *
 do_beep (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	d(fprintf (stderr, "beep\n"));
 
@@ -946,7 +941,7 @@ do_beep (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDri
 static ESExpResult *
 play_sound (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	d(fprintf (stderr, "play sound\n"));
 
@@ -961,7 +956,7 @@ play_sound (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilter
 static ESExpResult *
 do_only_once (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	d(fprintf (stderr, "only once\n"));
 
@@ -975,7 +970,7 @@ do_only_once (struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFilt
 static CamelFolder *
 open_folder (CamelFilterDriver *driver, const gchar *folder_url)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	CamelFolder *camelfolder;
 
 	/* we have a lookup table of currently open folders */
@@ -1012,7 +1007,7 @@ close_folder (gpointer key, gpointer value, gpointer data)
 {
 	CamelFolder *folder = value;
 	CamelFilterDriver *driver = data;
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	p->closed++;
 	g_free (key);
@@ -1030,7 +1025,7 @@ close_folder (gpointer key, gpointer value, gpointer data)
 static gint
 close_folders (CamelFilterDriver *driver)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	report_status(driver, CAMEL_FILTER_STATUS_PROGRESS, 0, _("Syncing folders"));
 
@@ -1054,7 +1049,7 @@ free_key (gpointer key, gpointer value, gpointer user_data)
 static void
 camel_filter_driver_log (CamelFilterDriver *driver, enum filter_log_t status, const gchar *desc, ...)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 
 	if (p->logfile) {
 		gchar *str = NULL;
@@ -1109,7 +1104,7 @@ struct _run_only_once {
 static gboolean
 run_only_once (gpointer key, gchar *action, struct _run_only_once *data)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (data->driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (data->driver);
 	CamelException *ex = data->ex;
 	ESExpResult *r;
 
@@ -1118,18 +1113,20 @@ run_only_once (gpointer key, gchar *action, struct _run_only_once *data)
 	e_sexp_input_text (p->eval, action, strlen (action));
 	if (e_sexp_parse (p->eval) == -1) {
 		if (!camel_exception_is_set (ex))
-			camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
-					      _("Error parsing filter: %s: %s"),
-					      e_sexp_error (p->eval), action);
+			camel_exception_setv (
+				ex, CAMEL_EXCEPTION_SYSTEM,
+				_("Error parsing filter: %s: %s"),
+				e_sexp_error (p->eval), action);
 		goto done;
 	}
 
 	r = e_sexp_eval (p->eval);
 	if (r == NULL) {
 		if (!camel_exception_is_set (ex))
-			camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
-					      _("Error executing filter: %s: %s"),
-					      e_sexp_error (p->eval), action);
+			camel_exception_setv (
+				ex, CAMEL_EXCEPTION_SYSTEM,
+				_("Error executing filter: %s: %s"),
+				e_sexp_error (p->eval), action);
 		goto done;
 	}
 
@@ -1151,9 +1148,10 @@ run_only_once (gpointer key, gchar *action, struct _run_only_once *data)
  * Flush all of the only-once filter actions.
  **/
 void
-camel_filter_driver_flush (CamelFilterDriver *driver, CamelException *ex)
+camel_filter_driver_flush (CamelFilterDriver *driver,
+                           CamelException *ex)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	struct _run_only_once data;
 
 	if (!p->only_once)
@@ -1200,9 +1198,12 @@ decode_flags_from_xev(const gchar *xev, CamelMessageInfoBase *mi)
  *
  **/
 gint
-camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, const gchar *original_source_url, CamelException *ex)
+camel_filter_driver_filter_mbox (CamelFilterDriver *driver,
+                                 const gchar *mbox,
+                                 const gchar *original_source_url,
+                                 CamelException *ex)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	CamelMimeParser *mp = NULL;
 	gchar *source_url = NULL;
 	gint fd = -1;
@@ -1214,7 +1215,9 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
 
 	fd = g_open (mbox, O_RDONLY|O_BINARY, 0);
 	if (fd == -1) {
-		camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Unable to open spool folder"));
+		camel_exception_set (
+			ex, CAMEL_EXCEPTION_SYSTEM,
+			_("Unable to open spool folder"));
 		goto fail;
 	}
 	/* to get the filesize */
@@ -1223,7 +1226,9 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
 	mp = camel_mime_parser_new ();
 	camel_mime_parser_scan_from (mp, TRUE);
 	if (camel_mime_parser_init_with_fd (mp, fd) == -1) {
-		camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Unable to process spool folder"));
+		camel_exception_set (
+			ex, CAMEL_EXCEPTION_SYSTEM,
+			_("Unable to process spool folder"));
 		goto fail;
 	}
 	fd = -1;
@@ -1232,7 +1237,8 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
 
 	while (camel_mime_parser_step (mp, 0, 0) == CAMEL_MIME_PARSER_STATE_FROM) {
 		CamelMessageInfo *info;
-		CamelMimeMessage *msg;
+		CamelMimeMessage *message;
+		CamelMimePart *mime_part;
 		gint pc = 0;
 		const gchar *xev;
 
@@ -1241,28 +1247,33 @@ camel_filter_driver_filter_mbox (CamelFilterDriver *driver, const gchar *mbox, c
 
 		report_status (driver, CAMEL_FILTER_STATUS_START, pc, _("Getting message %d (%d%%)"), i, pc);
 
-		msg = camel_mime_message_new ();
-		if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), mp) == -1) {
+		message = camel_mime_message_new ();
+		mime_part = CAMEL_MIME_PART (message);
+
+		if (camel_mime_part_construct_from_parser (mime_part, mp) == -1) {
 			camel_exception_set (ex, (errno==EINTR)?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM, _("Cannot open message"));
 			report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed on message %d"), i);
-			camel_object_unref (msg);
+			camel_object_unref (message);
 			goto fail;
 		}
 
-		info = camel_message_info_new_from_header(NULL, ((CamelMimePart *)msg)->headers);
+		info = camel_message_info_new_from_header(NULL, mime_part->headers);
 		/* Try and see if it has X-Evolution headers */
-		xev = camel_header_raw_find(&((CamelMimePart *)msg)->headers, "X-Evolution", NULL);
+		xev = camel_header_raw_find(&mime_part->headers, "X-Evolution", NULL);
 		if (xev)
 			decode_flags_from_xev (xev, (CamelMessageInfoBase *)info);
 
 		((CamelMessageInfoBase *)info)->size = camel_mime_parser_tell(mp) - last;
 
 		last = camel_mime_parser_tell(mp);
-		status = camel_filter_driver_filter_message (driver, msg, info, NULL, NULL, source_url,
-							     original_source_url ? original_source_url : source_url, ex);
-		camel_object_unref (msg);
+		status = camel_filter_driver_filter_message (
+			driver, message, info, NULL, NULL, source_url,
+			original_source_url ? original_source_url : source_url, ex);
+		camel_object_unref (message);
 		if (camel_exception_is_set (ex) || status == -1) {
-			report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed on message %d"), i);
+			report_status (
+				driver, CAMEL_FILTER_STATUS_END, 100,
+				_("Failed on message %d"), i);
 			camel_message_info_free (info);
 			goto fail;
 		}
@@ -1310,10 +1321,14 @@ fail:
  *
  **/
 gint
-camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folder, CamelUIDCache *cache,
-				   GPtrArray *uids, gboolean remove, CamelException *ex)
+camel_filter_driver_filter_folder (CamelFilterDriver *driver,
+                                   CamelFolder *folder,
+                                   CamelUIDCache *cache,
+                                   GPtrArray *uids,
+                                   gboolean remove,
+                                   CamelException *ex)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	gboolean freeuids = FALSE;
 	CamelMessageInfo *info;
 	gchar *source_url, *service_url;
@@ -1339,20 +1354,23 @@ camel_filter_driver_filter_folder (CamelFilterDriver *driver, CamelFolder *folde
 		report_status (driver, CAMEL_FILTER_STATUS_START, pc, _("Getting message %d of %d"), i+1,
 			       uids->len);
 
-		if (camel_folder_has_summary_capability (folder))
+		if (camel_folder_has_summary_capability (folder))                                    
 			info = camel_folder_get_message_info (folder, uids->pdata[i]);
 		else
 			info = NULL;
 
-		status = camel_filter_driver_filter_message (driver, NULL, info, uids->pdata[i],
-							     folder, source_url, source_url, ex);
+		status = camel_filter_driver_filter_message (
+			driver, NULL, info, uids->pdata[i],
+			folder, source_url, source_url, ex);
 
 		if (camel_folder_has_summary_capability (folder))
 			camel_folder_free_message_info (folder, info);
 
 		if (camel_exception_is_set (ex) || status == -1) {
-			report_status (driver, CAMEL_FILTER_STATUS_END, 100, _("Failed at message %d of %d"),
-				       i+1, uids->len);
+			report_status (
+				driver, CAMEL_FILTER_STATUS_END, 100,
+				_("Failed at message %d of %d"),
+				i+1, uids->len);
 			status = -1;
 			break;
 		}
@@ -1395,8 +1413,7 @@ get_message_cb (gpointer data, CamelException *ex)
 	CamelMimeMessage *message;
 
 	if (p->message) {
-		message = p->message;
-		camel_object_ref (message);
+		message = camel_object_ref (p->message);
 	} else {
 		const gchar *uid;
 
@@ -1436,13 +1453,16 @@ get_message_cb (gpointer data, CamelException *ex)
  *
  **/
 gint
-camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage *message,
-				    CamelMessageInfo *info, const gchar *uid,
-				    CamelFolder *source, const gchar *source_url,
-				    const gchar *original_source_url,
-				    CamelException *ex)
+camel_filter_driver_filter_message (CamelFilterDriver *driver,
+                                    CamelMimeMessage *message,
+                                    CamelMessageInfo *info,
+                                    const gchar *uid,
+                                    CamelFolder *source,
+                                    const gchar *source_url,
+                                    const gchar *original_source_url,
+                                    CamelException *ex)
 {
-	struct _CamelFilterDriverPrivate *p = _PRIVATE (driver);
+	struct _CamelFilterDriverPrivate *p = CAMEL_FILTER_DRIVER_GET_PRIVATE (driver);
 	struct _filter_rule *node;
 	gboolean freeinfo = FALSE;
 	gboolean filtered = FALSE;
@@ -1502,9 +1522,10 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
 		data.p = p;
 		data.source_url = original_source_url;
 
-		result = camel_filter_search_match (p->session, get_message_cb, &data, p->info,
-						    original_source_url ? original_source_url : source_url,
-						    node->match, p->ex);
+		result = camel_filter_search_match (
+			p->session, get_message_cb, &data, p->info,
+			original_source_url ? original_source_url : source_url,
+			node->match, p->ex);
 
 		switch (result) {
 		case CAMEL_SEARCH_ERROR:
@@ -1520,8 +1541,9 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
 			/* perform necessary filtering actions */
 			e_sexp_input_text (p->eval, node->action, strlen (node->action));
 			if (e_sexp_parse (p->eval) == -1) {
-				camel_exception_setv (ex, 1, _("Error parsing filter: %s: %s"),
-						      e_sexp_error (p->eval), node->action);
+				camel_exception_setv (
+					ex, 1, _("Error parsing filter: %s: %s"),
+					e_sexp_error (p->eval), node->action);
 				goto error;
 			}
 			r = e_sexp_eval (p->eval);
@@ -1529,8 +1551,9 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
 				goto error;
 
 			if (r == NULL) {
-				camel_exception_setv (ex, 1, _("Error executing filter: %s: %s"),
-						      e_sexp_error (p->eval), node->action);
+				camel_exception_setv (
+					ex, 1, _("Error executing filter: %s: %s"),
+					e_sexp_error (p->eval), node->action);
 				goto error;
 			}
 			e_sexp_result_free (p->eval, r);
@@ -1565,7 +1588,9 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
 
 			uids = g_ptr_array_new ();
 			g_ptr_array_add (uids, (gchar *) p->uid);
-			camel_folder_transfer_messages_to (p->source, uids, p->defaultfolder, NULL, FALSE, p->ex);
+			camel_folder_transfer_messages_to (
+				p->source, uids, p->defaultfolder,
+				NULL, FALSE, p->ex);
 			g_ptr_array_free (uids, TRUE);
 		} else {
 			if (p->message == NULL) {
@@ -1574,7 +1599,9 @@ camel_filter_driver_filter_message (CamelFilterDriver *driver, CamelMimeMessage
 					goto error;
 			}
 
-			camel_folder_append_message (p->defaultfolder, p->message, p->info, NULL, p->ex);
+			camel_folder_append_message (
+				p->defaultfolder, p->message,
+				p->info, NULL, p->ex);
 		}
 	}
 
diff --git a/camel/camel-filter-search.c b/camel/camel-filter-search.c
index ed76a38..e92c159 100644
--- a/camel/camel-filter-search.c
+++ b/camel/camel-filter-search.c
@@ -37,7 +37,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 
 #ifndef G_OS_WIN32
@@ -164,25 +163,27 @@ check_header (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMes
 			}
 		} else {
 			CamelMimeMessage *message;
+			CamelMimePart *mime_part;
 			struct _camel_header_raw *header;
 			const gchar *charset = NULL;
 			camel_search_t type = CAMEL_SEARCH_TYPE_ENCODED;
 			CamelContentType *ct;
 
 			message = camel_filter_search_get_message (fms, f);
+			mime_part = CAMEL_MIME_PART (message);
 
 			/* FIXME: what about Resent-To, Resent-Cc and Resent-From? */
 			if (g_ascii_strcasecmp("to", name) == 0 || g_ascii_strcasecmp("cc", name) == 0 || g_ascii_strcasecmp("from", name) == 0)
 				type = CAMEL_SEARCH_TYPE_ADDRESS_ENCODED;
 			else if (message) {
-				ct = camel_mime_part_get_content_type (CAMEL_MIME_PART (message));
+				ct = camel_mime_part_get_content_type (mime_part);
 				if (ct) {
 					charset = camel_content_type_param (ct, "charset");
 					charset = camel_iconv_charset_name (charset);
 				}
 			}
 
-			for (header = ((CamelMimePart *)message)->headers; header && !matched; header = header->next) {
+			for (header = mime_part->headers; header && !matched; header = header->next) {
 				if (!g_ascii_strcasecmp(header->name, name)) {
 					for (i=1; i<argc && !matched; i++) {
 						if (argv[i]->type == ESEXP_RES_STRING)
@@ -274,12 +275,14 @@ header_regex (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMes
 static gchar *
 get_full_header (CamelMimeMessage *message)
 {
-	CamelMimePart *mp = CAMEL_MIME_PART (message);
+	CamelMimePart *mime_part;
 	GString *str = g_string_new ("");
 	gchar   *ret;
 	struct _camel_header_raw *h;
 
-	for (h = mp->headers; h; h = h->next) {
+	mime_part = CAMEL_MIME_PART (message);
+
+	for (h = mime_part->headers; h; h = h->next) {
 		if (h->value != NULL) {
 			g_string_append (str, h->name);
 			if (isspace (h->value[0]))
@@ -575,9 +578,10 @@ run_command (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMess
 				       &error)) {
 		g_ptr_array_free (args, TRUE);
 
-		camel_exception_setv (fms->ex, CAMEL_EXCEPTION_SYSTEM,
-				      _("Failed to create child process '%s': %s"),
-				      argv[0]->value.string, error->message);
+		camel_exception_setv (
+			fms->ex, CAMEL_EXCEPTION_SYSTEM,
+			_("Failed to create child process '%s': %s"),
+			argv[0]->value.string, error->message);
 		g_error_free (error);
 		return -1;
 	}
@@ -587,7 +591,8 @@ run_command (struct _ESExp *f, gint argc, struct _ESExpResult **argv, FilterMess
 	message = camel_filter_search_get_message (fms, f);
 
 	stream = camel_stream_fs_new_with_fd (pipe_to_child);
-	camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream);
+	camel_data_wrapper_write_to_stream (
+		CAMEL_DATA_WRAPPER (message), stream);
 	camel_stream_flush (stream);
 	camel_object_unref (stream);
 
@@ -731,17 +736,20 @@ camel_filter_search_match (CamelSession *session,
 	e_sexp_input_text (sexp, expression, strlen (expression));
 	if (e_sexp_parse (sexp) == -1) {
 		if (!camel_exception_is_set (ex))
-			/* A filter search is a search through your filters, ie. your filters is the corpus being searched thru. */
-			camel_exception_setv (ex, 1, _("Error executing filter search: %s: %s"),
-					      e_sexp_error (sexp), expression);
+			/* A filter search is a search through your filters,
+			 * ie. your filters is the corpus being searched thru. */
+			camel_exception_setv (
+				ex, 1, _("Error executing filter search: %s: %s"),
+				e_sexp_error (sexp), expression);
 		goto error;
 	}
 
 	result = e_sexp_eval (sexp);
 	if (result == NULL) {
 		if (!camel_exception_is_set (ex))
-			camel_exception_setv (ex, 1, _("Error executing filter search: %s: %s"),
-					      e_sexp_error (sexp), expression);
+			camel_exception_setv (
+				ex, 1, _("Error executing filter search: %s: %s"),
+				e_sexp_error (sexp), expression);
 		goto error;
 	}
 
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index 5d53e8e..94c18a6 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -93,65 +93,61 @@ static ESExpResult *search_message_location(struct _ESExp *f, gint argc, struct
 
 static ESExpResult *search_dummy(struct _ESExp *f, gint argc, struct _ESExpResult **argv, CamelFolderSearch *search);
 
-static void camel_folder_search_class_init (CamelFolderSearchClass *klass);
-static void camel_folder_search_init       (CamelFolderSearch *obj);
-static void camel_folder_search_finalize   (CamelObject *obj);
-
 static gint read_uid_callback (gpointer  ref, gint ncol, gchar ** cols, gchar **name);
 
 static CamelObjectClass *camel_folder_search_parent;
 
 static void
-camel_folder_search_class_init (CamelFolderSearchClass *klass)
+folder_search_finalize (CamelObject *obj)
 {
-	camel_folder_search_parent = camel_type_get_global_classfuncs (camel_object_get_type ());
+	CamelFolderSearch *search = (CamelFolderSearch *)obj;
+	struct _CamelFolderSearchPrivate *p = _PRIVATE(obj);
 
-	klass->not = search_not;
-
-	klass->match_all = search_match_all;
-	klass->match_threads = search_match_threads;
-	klass->body_contains = search_body_contains;
-	klass->body_regex = search_body_regex;
-	klass->header_contains = search_header_contains;
-	klass->header_matches = search_header_matches;
-	klass->header_starts_with = search_header_starts_with;
-	klass->header_ends_with = search_header_ends_with;
-	klass->header_exists = search_header_exists;
-	klass->header_soundex = search_header_soundex;
-	klass->header_regex = search_header_regex;
-	klass->header_full_regex = search_header_full_regex;
-	klass->user_tag = search_user_tag;
-	klass->user_flag = search_user_flag;
-	klass->system_flag = search_system_flag;
-	klass->get_sent_date = search_get_sent_date;
-	klass->get_received_date = search_get_received_date;
-	klass->get_current_date = search_get_current_date;
-	klass->get_size = search_get_size;
-	klass->uid = search_uid;
-	klass->message_location = search_message_location;
+	if (search->sexp)
+		e_sexp_unref(search->sexp);
+
+	g_free(search->last_search);
+	g_free(p);
 }
 
 static void
-camel_folder_search_init (CamelFolderSearch *obj)
+camel_folder_search_class_init (CamelFolderSearchClass *class)
 {
-	struct _CamelFolderSearchPrivate *p;
-
-	p = _PRIVATE(obj) = g_malloc0(sizeof(*p));
+	camel_folder_search_parent = camel_type_get_global_classfuncs (camel_object_get_type ());
 
-	obj->sexp = e_sexp_new();
+	class->not = search_not;
+
+	class->match_all = search_match_all;
+	class->match_threads = search_match_threads;
+	class->body_contains = search_body_contains;
+	class->body_regex = search_body_regex;
+	class->header_contains = search_header_contains;
+	class->header_matches = search_header_matches;
+	class->header_starts_with = search_header_starts_with;
+	class->header_ends_with = search_header_ends_with;
+	class->header_exists = search_header_exists;
+	class->header_soundex = search_header_soundex;
+	class->header_regex = search_header_regex;
+	class->header_full_regex = search_header_full_regex;
+	class->user_tag = search_user_tag;
+	class->user_flag = search_user_flag;
+	class->system_flag = search_system_flag;
+	class->get_sent_date = search_get_sent_date;
+	class->get_received_date = search_get_received_date;
+	class->get_current_date = search_get_current_date;
+	class->get_size = search_get_size;
+	class->uid = search_uid;
+	class->message_location = search_message_location;
 }
 
 static void
-camel_folder_search_finalize (CamelObject *obj)
+camel_folder_search_init (CamelFolderSearch *obj)
 {
-	CamelFolderSearch *search = (CamelFolderSearch *)obj;
-	struct _CamelFolderSearchPrivate *p = _PRIVATE(obj);
+	struct _CamelFolderSearchPrivate *p;
 
-	if (search->sexp)
-		e_sexp_unref(search->sexp);
+	p = _PRIVATE(obj) = g_malloc0(sizeof(*p));
 
-	g_free(search->last_search);
-	g_free(p);
+	obj->sexp = e_sexp_new();
 }
 
 CamelType
@@ -166,67 +162,63 @@ camel_folder_search_get_type (void)
 					    (CamelObjectClassInitFunc) camel_folder_search_class_init,
 					    NULL,
 					    (CamelObjectInitFunc) camel_folder_search_init,
-					    (CamelObjectFinalizeFunc) camel_folder_search_finalize);
+					    (CamelObjectFinalizeFunc) folder_search_finalize);
 	}
 
 	return type;
 }
 
-#ifdef offsetof
-#define CAMEL_STRUCT_OFFSET(type, field)        ((gint) offsetof (type, field))
-#else
-#define CAMEL_STRUCT_OFFSET(type, field)        ((gint) ((gchar *) &((type *) 0)->field))
-#endif
-
 static struct {
 	const gchar *name;
 	gint offset;
 	gint flags;		/* 0x02 = immediate, 0x01 = always enter */
 } builtins[] = {
 	/* these have default implementations in e-sexp */
-	{ "and", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, and), 2 },
-	{ "or", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, or), 2 },
+	{ "and", G_STRUCT_OFFSET(CamelFolderSearchClass, and), 2 },
+	{ "or", G_STRUCT_OFFSET(CamelFolderSearchClass, or), 2 },
 	/* we need to override this one though to implement an 'array not' */
-	{ "not", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, not), 0 },
-	{ "<", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, lt), 2 },
-	{ ">", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, gt), 2 },
-	{ "=", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, eq), 2 },
+	{ "not", G_STRUCT_OFFSET(CamelFolderSearchClass, not), 0 },
+	{ "<", G_STRUCT_OFFSET(CamelFolderSearchClass, lt), 2 },
+	{ ">", G_STRUCT_OFFSET(CamelFolderSearchClass, gt), 2 },
+	{ "=", G_STRUCT_OFFSET(CamelFolderSearchClass, eq), 2 },
 
 	/* these we have to use our own default if there is none */
 	/* they should all be defined in the language? so it parses, or should they not?? */
-	{ "match-all", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, match_all), 3 },
-	{ "match-threads", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, match_threads), 3 },
-	{ "body-contains", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, body_contains), 1 },
-	{ "body-regex",  CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, body_regex), 1  },
-	{ "header-contains", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_contains), 1 },
-	{ "header-matches", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_matches), 1 },
-	{ "header-starts-with", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_starts_with), 1 },
-	{ "header-ends-with", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_ends_with), 1 },
-	{ "header-exists", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_exists), 1 },
-	{ "header-soundex", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_soundex), 1 },
-	{ "header-regex", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_regex), 1 },
-	{ "header-full-regex", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, header_full_regex), 1 },
-	{ "user-tag", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, user_tag), 1 },
-	{ "user-flag", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, user_flag), 1 },
-	{ "system-flag", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, system_flag), 1 },
-	{ "get-sent-date", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, get_sent_date), 1 },
-	{ "get-received-date", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, get_received_date), 1 },
-	{ "get-current-date", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, get_current_date), 1 },
-	{ "get-size", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, get_size), 1 },
-	{ "uid", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, uid), 1 },
-	{ "message-location", CAMEL_STRUCT_OFFSET(CamelFolderSearchClass, message_location), 1 },
+	{ "match-all", G_STRUCT_OFFSET(CamelFolderSearchClass, match_all), 3 },
+	{ "match-threads", G_STRUCT_OFFSET(CamelFolderSearchClass, match_threads), 3 },
+	{ "body-contains", G_STRUCT_OFFSET(CamelFolderSearchClass, body_contains), 1 },
+	{ "body-regex",  G_STRUCT_OFFSET(CamelFolderSearchClass, body_regex), 1  },
+	{ "header-contains", G_STRUCT_OFFSET(CamelFolderSearchClass, header_contains), 1 },
+	{ "header-matches", G_STRUCT_OFFSET(CamelFolderSearchClass, header_matches), 1 },
+	{ "header-starts-with", G_STRUCT_OFFSET(CamelFolderSearchClass, header_starts_with), 1 },
+	{ "header-ends-with", G_STRUCT_OFFSET(CamelFolderSearchClass, header_ends_with), 1 },
+	{ "header-exists", G_STRUCT_OFFSET(CamelFolderSearchClass, header_exists), 1 },
+	{ "header-soundex", G_STRUCT_OFFSET(CamelFolderSearchClass, header_soundex), 1 },
+	{ "header-regex", G_STRUCT_OFFSET(CamelFolderSearchClass, header_regex), 1 },
+	{ "header-full-regex", G_STRUCT_OFFSET(CamelFolderSearchClass, header_full_regex), 1 },
+	{ "user-tag", G_STRUCT_OFFSET(CamelFolderSearchClass, user_tag), 1 },
+	{ "user-flag", G_STRUCT_OFFSET(CamelFolderSearchClass, user_flag), 1 },
+	{ "system-flag", G_STRUCT_OFFSET(CamelFolderSearchClass, system_flag), 1 },
+	{ "get-sent-date", G_STRUCT_OFFSET(CamelFolderSearchClass, get_sent_date), 1 },
+	{ "get-received-date", G_STRUCT_OFFSET(CamelFolderSearchClass, get_received_date), 1 },
+	{ "get-current-date", G_STRUCT_OFFSET(CamelFolderSearchClass, get_current_date), 1 },
+	{ "get-size", G_STRUCT_OFFSET(CamelFolderSearchClass, get_size), 1 },
+	{ "uid", G_STRUCT_OFFSET(CamelFolderSearchClass, uid), 1 },
+	{ "message-location", G_STRUCT_OFFSET(CamelFolderSearchClass, message_location), 1 },
 };
 
 void
 camel_folder_search_construct (CamelFolderSearch *search)
 {
 	gint i;
-	CamelFolderSearchClass *klass = (CamelFolderSearchClass *)CAMEL_OBJECT_GET_CLASS(search);
+	CamelFolderSearchClass *class;
+
+	class = CAMEL_FOLDER_SEARCH_GET_CLASS (search);
 
 	for (i = 0; i < G_N_ELEMENTS (builtins); i++) {
 		gpointer func;
 		/* c is sure messy sometimes */
-		func = *((gpointer *)(((gchar *)klass)+builtins[i].offset));
+		func = *((gpointer *)(((gchar *)class)+builtins[i].offset));
 		if (func == NULL && builtins[i].flags&1) {
 			g_warning("Search class doesn't implement '%s' method: %s", builtins[i].name, camel_type_to_name(CAMEL_OBJECT_GET_CLASS(search)));
 			func = (gpointer)search_dummy;
@@ -256,9 +248,11 @@ camel_folder_search_construct (CamelFolderSearch *search)
 CamelFolderSearch *
 camel_folder_search_new (void)
 {
-	CamelFolderSearch *new = CAMEL_FOLDER_SEARCH (camel_object_new (camel_folder_search_get_type ()));
+	CamelFolderSearch *new;
 
+	new = CAMEL_FOLDER_SEARCH (camel_object_new (camel_folder_search_get_type ()));
 	camel_folder_search_construct(new);
+
 	return new;
 }
 
@@ -307,10 +301,10 @@ void
 camel_folder_search_set_body_index(CamelFolderSearch *search, CamelIndex *index)
 {
 	if (search->body_index)
-		camel_object_unref((CamelObject *)search->body_index);
+		camel_object_unref (search->body_index);
 	search->body_index = index;
 	if (index)
-		camel_object_ref((CamelObject *)index);
+		camel_object_ref (index);
 }
 
 /**
@@ -332,7 +326,9 @@ camel_folder_search_set_body_index(CamelFolderSearch *search, CamelIndex *index)
  * This must only be freed by camel_folder_search_free_result.
  **/
 GPtrArray *
-camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *expr, CamelException *ex)
+camel_folder_search_execute_expression (CamelFolderSearch *search,
+                                        const gchar *expr,
+                                        CamelException *ex)
 {
 	ESExpResult *r;
 	GPtrArray *matches;
@@ -347,7 +343,10 @@ camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *e
 	    || strcmp(search->last_search, expr)) {
 		e_sexp_input_text(search->sexp, expr, strlen(expr));
 		if (e_sexp_parse(search->sexp) == -1) {
-			camel_exception_setv(ex, 1, _("Cannot parse search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+			camel_exception_setv (
+				ex, 1,
+				_("Cannot parse search expression: %s:\n%s"),
+				e_sexp_error(search->sexp), expr);
 			return NULL;
 		}
 
@@ -357,7 +356,10 @@ camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *e
 	r = e_sexp_eval(search->sexp);
 	if (r == NULL) {
 		if (!camel_exception_is_set(ex))
-			camel_exception_setv(ex, 1, _("Error executing search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+			camel_exception_setv (
+				ex, 1,
+				_("Error executing search expression: %s:\n%s"),
+				e_sexp_error(search->sexp), expr);
 		return NULL;
 	}
 
@@ -423,7 +425,9 @@ camel_folder_search_execute_expression(CamelFolderSearch *search, const gchar *e
  **/
 
 guint32
-camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelException *ex)
+camel_folder_search_count (CamelFolderSearch *search,
+                           const gchar *expr,
+                           CamelException *ex)
 {
 	ESExpResult *r;
 	GPtrArray *summary_set;
@@ -451,7 +455,10 @@ camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelExc
 		    || strcmp(search->last_search, expr)) {
 			e_sexp_input_text(search->sexp, expr, strlen(expr));
 			if (e_sexp_parse(search->sexp) == -1) {
-				camel_exception_setv(ex, 1, _("Cannot parse search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+				camel_exception_setv (
+					ex, 1,
+					_("Cannot parse search expression: %s:\n%s"),
+					e_sexp_error(search->sexp), expr);
 				goto fail;
 			}
 
@@ -461,7 +468,10 @@ camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelExc
 		r = e_sexp_eval(search->sexp);
 		if (r == NULL) {
 			if (!camel_exception_is_set(ex))
-				camel_exception_setv(ex, 1, _("Error executing search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+				camel_exception_setv (
+					ex, 1,
+					_("Error executing search expression: %s:\n%s"),
+					e_sexp_error(search->sexp), expr);
 			goto fail;
 		}
 
@@ -507,11 +517,11 @@ camel_folder_search_count(CamelFolderSearch *search, const gchar *expr, CamelExc
 			const gchar *exception = camel_exception_get_description (ex);
 			if (strncmp(exception, "no such table", 13) == 0) {
 				d(g_warning ("Error during searching %s: %s\n", tmp, exception));
-				camel_exception_clear (ex); /* Suppress no such table */
+				/* Suppress no such table */
+				camel_exception_clear (ex);
 			}
 		}
 		g_free (tmp);
-
 	}
 
 fail:
@@ -567,7 +577,10 @@ do_search_in_memory (const gchar *expr)
  * Returns:
  **/
 GPtrArray *
-camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArray *uids, CamelException *ex)
+camel_folder_search_search (CamelFolderSearch *search,
+                            const gchar *expr,
+                            GPtrArray *uids,
+                            CamelException *ex)
 {
 	ESExpResult *r;
 	GPtrArray *matches = NULL, *summary_set;
@@ -606,7 +619,10 @@ camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArr
 		    || strcmp(search->last_search, expr)) {
 			e_sexp_input_text(search->sexp, expr, strlen(expr));
 			if (e_sexp_parse(search->sexp) == -1) {
-				camel_exception_setv(ex, 1, _("Cannot parse search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+				camel_exception_setv (
+					ex, 1,
+					_("Cannot parse search expression: %s:\n%s"),
+					e_sexp_error(search->sexp), expr);
 				goto fail;
 			}
 
@@ -616,7 +632,10 @@ camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArr
 		r = e_sexp_eval(search->sexp);
 		if (r == NULL) {
 			if (!camel_exception_is_set(ex))
-				camel_exception_setv(ex, 1, _("Error executing search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+				camel_exception_setv (
+					ex, 1,
+					_("Error executing search expression: %s:\n%s"),
+					e_sexp_error(search->sexp), expr);
 			goto fail;
 		}
 
@@ -665,7 +684,8 @@ camel_folder_search_search(CamelFolderSearch *search, const gchar *expr, GPtrArr
 			const gchar *exception = camel_exception_get_description (ex);
 			if (strncmp(exception, "no such table", 13) == 0) {
 				d(g_warning ("Error during searching %s: %s\n", tmp, exception));
-				camel_exception_clear (ex); /* Suppress no such table */
+				/* Suppress no such table */
+				camel_exception_clear (ex);
 			}
 		}
 		g_free (tmp);
@@ -896,7 +916,7 @@ static ESExpResult *
 search_match_threads(struct _ESExp *f, gint argc, struct _ESExpTerm **argv, CamelFolderSearch *search)
 {
 	ESExpResult *r;
-	struct _CamelFolderSearchPrivate *p = search->priv;
+	CamelFolderSearchPrivate *p = search->priv;
 	gint i, type;
 	GHashTable *results;
 	gchar *error_msg;
@@ -1292,7 +1312,10 @@ htand(gchar *key, gint value, struct IterData *iter_data)
 }
 
 static gint
-match_message_index(CamelIndex *idx, const gchar *uid, const gchar *match, CamelException *ex)
+match_message_index (CamelIndex *idx,
+                     const gchar *uid,
+                     const gchar *match,
+                     CamelException *ex)
 {
 	CamelIndexCursor *wc, *nc;
 	const gchar *word, *name;
@@ -1307,11 +1330,11 @@ match_message_index(CamelIndex *idx, const gchar *uid, const gchar *match, Camel
 				if (nc) {
 					while (!truth && (name = camel_index_cursor_next(nc)))
 						truth = strcmp(name, uid) == 0;
-					camel_object_unref((CamelObject *)nc);
+					camel_object_unref (nc);
 				}
 			}
 		}
-		camel_object_unref((CamelObject *)wc);
+		camel_object_unref (wc);
 	}
 
 	return truth;
@@ -1329,7 +1352,9 @@ or
 
 /* returns messages which contain all words listed in words */
 static GPtrArray *
-match_words_index(CamelFolderSearch *search, struct _camel_search_words *words, CamelException *ex)
+match_words_index (CamelFolderSearch *search,
+                   struct _camel_search_words *words,
+                   CamelException *ex)
 {
 	GPtrArray *result = g_ptr_array_new();
 	GHashTable *ht = g_hash_table_new(g_str_hash, g_str_equal);
@@ -1354,12 +1379,12 @@ match_words_index(CamelFolderSearch *search, struct _camel_search_words *words,
 								mask = (GPOINTER_TO_INT(g_hash_table_lookup(ht, name))) | (1<<i);
 								g_hash_table_insert(ht, (gchar *) camel_pstring_peek(name), GINT_TO_POINTER(mask));
 						}
-						camel_object_unref((CamelObject *)nc);
+						camel_object_unref (nc);
 					}
 				}
 			}
 		}
-		camel_object_unref((CamelObject *)wc);
+		camel_object_unref (wc);
 
 		lambdafoo.uids = result;
 		lambdafoo.count = (1<<words->len) - 1;
@@ -1421,28 +1446,31 @@ match_words_1message (CamelDataWrapper *object, struct _camel_search_words *word
 }
 
 static gboolean
-match_words_message(CamelFolder *folder, const gchar *uid, struct _camel_search_words *words, CamelException *ex)
+match_words_message (CamelFolder *folder,
+                     const gchar *uid,
+                     struct _camel_search_words *words,
+                     CamelException *ex)
 {
 	guint32 mask;
 	CamelMimeMessage *msg;
 	CamelException x = CAMEL_EXCEPTION_INITIALISER;
-	gint truth;
+	gint truth = FALSE;
 
 	msg = camel_folder_get_message(folder, uid, &x);
 	if (msg) {
 		mask = 0;
 		truth = match_words_1message((CamelDataWrapper *)msg, words, &mask);
-		camel_object_unref((CamelObject *)msg);
-	} else {
-		camel_exception_clear(&x);
-		truth = FALSE;
-	}
+		camel_object_unref (msg);
+	} else
+		camel_exception_clear (&x);
 
 	return truth;
 }
 
 static GPtrArray *
-match_words_messages(CamelFolderSearch *search, struct _camel_search_words *words, CamelException *ex)
+match_words_messages (CamelFolderSearch *search,
+                      struct _camel_search_words *words,
+                      CamelException *ex)
 {
 	gint i;
 	GPtrArray *matches = g_ptr_array_new();
@@ -1588,7 +1616,7 @@ search_body_regex (struct _ESExp *f, gint argc, struct _ESExpResult **argv, Came
 						g_ptr_array_add (r->value.ptrarray, uid);
 					}
 
-					camel_object_unref ((CamelObject *)message);
+					camel_object_unref (message);
 				} else {
 					camel_exception_clear (&x);
 				}
diff --git a/camel/camel-folder-search.h b/camel/camel-folder-search.h
index 7b947dd..2fb7078 100644
--- a/camel/camel-folder-search.h
+++ b/camel/camel-folder-search.h
@@ -34,6 +34,8 @@
 #define CAMEL_FOLDER_SEARCH(obj)         CAMEL_CHECK_CAST (obj, camel_folder_search_get_type (), CamelFolderSearch)
 #define CAMEL_FOLDER_SEARCH_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_folder_search_get_type (), CamelFolderSearchClass)
 #define CAMEL_IS_FOLDER_SEARCH(obj)      CAMEL_CHECK_TYPE (obj, camel_folder_search_get_type ())
+#define CAMEL_FOLDER_SEARCH_GET_CLASS(obj) \
+	((CamelFolderSearchClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index e6640b5..ac3b2c5 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -33,7 +33,6 @@
 #include <fcntl.h>
 #include <errno.h>
 
-#include <glib.h>
 #include <glib-object.h>
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
@@ -61,10 +60,6 @@
 #include "camel-vee-folder.h"
 #include "camel-mime-part-utils.h"
 
-/* To switch between e-memchunk and g-alloc */
-#define ALWAYS_ALLOC 1
-#define USE_GSLICE 1
-
 /* Make 5 minutes as default cache drop */
 #define SUMMARY_CACHE_DROP 300 
 #define dd(x) if (camel_debug("sync")) x
@@ -88,7 +83,7 @@ extern gint strdup_count, malloc_count, free_count;
 
 #define CAMEL_FOLDER_SUMMARY_VERSION (14)
 
-#define _PRIVATE(o) (((CamelFolderSummary *)(o))->priv)
+#define CAMEL_FOLDER_SUMMARY_GET_PRIVATE(o) (((CamelFolderSummary *)(o))->priv)
 
 #define META_SUMMARY_SUFFIX_LEN 5 /* strlen("-meta") */
 
@@ -135,7 +130,7 @@ static gchar *next_uid_string(CamelFolderSummary *s);
 static CamelMessageContentInfo * summary_build_content_info(CamelFolderSummary *s, CamelMessageInfo *msginfo, CamelMimeParser *mp);
 static CamelMessageContentInfo * summary_build_content_info_message(CamelFolderSummary *s, CamelMessageInfo *msginfo, CamelMimePart *object);
 
-static void camel_folder_summary_class_init (CamelFolderSummaryClass *klass);
+static void camel_folder_summary_class_init (CamelFolderSummaryClass *class);
 static void camel_folder_summary_init       (CamelFolderSummary *obj);
 static void camel_folder_summary_finalize   (CamelObject *obj);
 
@@ -147,12 +142,10 @@ camel_folder_summary_init (CamelFolderSummary *s)
 {
 	struct _CamelFolderSummaryPrivate *p;
 
-	p = _PRIVATE(s) = g_malloc0(sizeof(*p));
+	p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s) = g_malloc0(sizeof(*p));
 
 	p->filter_charset = g_hash_table_new (camel_strcase_hash, camel_strcase_equal);
 
-	s->message_info_size = sizeof(CamelMessageInfoBase);
-	s->content_info_size = sizeof(CamelMessageContentInfo);
 	p->flag_cache = g_hash_table_new (g_str_hash, g_str_equal);
 
 	s->message_info_chunks = NULL;
@@ -186,7 +179,7 @@ camel_folder_summary_init (CamelFolderSummary *s)
 
 static void free_o_name(gpointer key, gpointer value, gpointer data)
 {
-	camel_object_unref((CamelObject *)value);
+	camel_object_unref (value);
 	g_free(key);
 }
 
@@ -196,7 +189,7 @@ camel_folder_summary_finalize (CamelObject *obj)
 	struct _CamelFolderSummaryPrivate *p;
 	CamelFolderSummary *s = (CamelFolderSummary *)obj;
 
-	p = _PRIVATE(obj);
+	p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(obj);
 	g_hash_table_destroy (p->flag_cache);
 	if (s->timeout_handle)
 		g_source_remove (s->timeout_handle);
@@ -210,30 +203,23 @@ camel_folder_summary_finalize (CamelObject *obj)
 
 	g_free(s->summary_path);
 
-#ifndef ALWAYS_ALLOC
-	if (s->message_info_chunks)
-		e_memchunk_destroy(s->message_info_chunks);
-	if (s->content_info_chunks)
-		e_memchunk_destroy(s->content_info_chunks);
-#endif
-
 	if (p->filter_index)
-		camel_object_unref((CamelObject *)p->filter_index);
+		camel_object_unref (p->filter_index);
 	if (p->filter_64)
-		camel_object_unref((CamelObject *)p->filter_64);
+		camel_object_unref (p->filter_64);
 	if (p->filter_qp)
-		camel_object_unref((CamelObject *)p->filter_qp);
+		camel_object_unref (p->filter_qp);
 	if (p->filter_uu)
-		camel_object_unref((CamelObject *)p->filter_uu);
+		camel_object_unref (p->filter_uu);
 	if (p->filter_save)
-		camel_object_unref((CamelObject *)p->filter_save);
+		camel_object_unref (p->filter_save);
 	if (p->filter_html)
-		camel_object_unref((CamelObject *)p->filter_html);
+		camel_object_unref (p->filter_html);
 
 	if (p->filter_stream)
-		camel_object_unref((CamelObject *)p->filter_stream);
+		camel_object_unref (p->filter_stream);
 	if (p->index)
-		camel_object_unref((CamelObject *)p->index);
+		camel_object_unref (p->index);
 
 	/* Freeing memory occupied by meta-summary-header */
 	g_free(s->meta_summary->path);
@@ -318,14 +304,14 @@ camel_folder_summary_set_filename(CamelFolderSummary *s, const gchar *name)
 void
 camel_folder_summary_set_index(CamelFolderSummary *s, CamelIndex *index)
 {
-	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
+	struct _CamelFolderSummaryPrivate *p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s);
 
 	if (p->index)
-		camel_object_unref((CamelObject *)p->index);
+		camel_object_unref (p->index);
 
 	p->index = index;
 	if (index)
-		camel_object_ref((CamelObject *)index);
+		camel_object_ref (index);
 }
 
 /**
@@ -882,8 +868,7 @@ cfs_try_release_memory (CamelFolderSummary *s)
 		return TRUE;
 
 	m = camel_session_thread_msg_new(session, &remove_timeout_ops, sizeof(*m));
-	camel_object_ref (s);
-	m->summary = s;
+	m->summary = camel_object_ref (s);
 	camel_session_thread_queue(session, &m->msg, 0);
 
 	return TRUE;
@@ -1031,7 +1016,7 @@ camel_folder_summary_reload_from_db (CamelFolderSummary *s, CamelException *ex)
 	if (!g_getenv("CAMEL_FREE_INFOS") && !s->timeout_handle)
 		s->timeout_handle = g_timeout_add_seconds (SUMMARY_CACHE_DROP, (GSourceFunc) cfs_try_release_memory, s);
 
-	if (_PRIVATE(s)->need_preview) {
+	if (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->need_preview) {
 		struct _preview_update_msg *m;
 
 		m = camel_session_thread_msg_new(((CamelService *)s->folder->parent_store)->session, &preview_update_ops, sizeof(*m));
@@ -1052,7 +1037,7 @@ void
 camel_folder_summary_add_preview (CamelFolderSummary *s, CamelMessageInfo *info)
 {
 	CAMEL_SUMMARY_LOCK(s, summary_lock);
-	g_hash_table_insert (_PRIVATE(s)->preview_updates, (gchar *)info->uid, ((CamelMessageInfoBase *)info)->preview);
+	g_hash_table_insert (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->preview_updates, (gchar *)info->uid, ((CamelMessageInfoBase *)info)->preview);
 	CAMEL_SUMMARY_UNLOCK(s, summary_lock);
 }
 
@@ -1103,7 +1088,7 @@ camel_folder_summary_dump (CamelFolderSummary *s)
 GHashTable *
 camel_folder_summary_get_flag_cache (CamelFolderSummary *summary)
 {
-	struct _CamelFolderSummaryPrivate *p = _PRIVATE(summary);
+	struct _CamelFolderSummaryPrivate *p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(summary);
 
 	return p->flag_cache;
 }
@@ -1120,7 +1105,7 @@ camel_folder_summary_load_from_db (CamelFolderSummary *s, CamelException *ex)
 	gchar *folder_name;
 	gint ret = 0;
 	CamelException ex2;
-	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
+	struct _CamelFolderSummaryPrivate *p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s);
 
 	/* struct _db_pass_data data; */
 	d(printf ("\ncamel_folder_summary_load_from_db called \n"));
@@ -1612,11 +1597,11 @@ camel_folder_summary_save_to_db (CamelFolderSummary *s, CamelException *ex)
 	gint ret, count;
 
 	d(printf ("\ncamel_folder_summary_save_to_db called \n"));
-	if (_PRIVATE(s)->need_preview && g_hash_table_size(_PRIVATE(s)->preview_updates)) {
+	if (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->need_preview && g_hash_table_size(CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->preview_updates)) {
 		camel_db_begin_transaction (s->folder->parent_store->cdb_w, NULL);
 		CAMEL_SUMMARY_LOCK(s, summary_lock);
-		g_hash_table_foreach (_PRIVATE(s)->preview_updates, (GHFunc)msg_save_preview, s->folder);
-		g_hash_table_remove_all (_PRIVATE(s)->preview_updates);
+		g_hash_table_foreach (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->preview_updates, (GHFunc)msg_save_preview, s->folder);
+		g_hash_table_remove_all (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->preview_updates);
 		CAMEL_SUMMARY_UNLOCK(s, summary_lock);
 		camel_db_end_transaction (s->folder->parent_store->cdb_w, NULL);
 	}
@@ -2001,7 +1986,7 @@ camel_folder_summary_add (CamelFolderSummary *s, CamelMessageInfo *info)
 	/* FIXME[disk-summary] SHould we ref it or redesign it later on */
 	/* The uid array should have its own memory. We will unload the infos when not reqd.*/
 	g_ptr_array_add (s->uids, (gpointer) camel_pstring_strdup((camel_message_info_uid(info))));
-	g_hash_table_replace (_PRIVATE(s)->flag_cache, (gchar *)info->uid, GUINT_TO_POINTER(camel_message_info_flags(info)));
+	g_hash_table_replace (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->flag_cache, (gchar *)info->uid, GUINT_TO_POINTER(camel_message_info_flags(info)));
 
 	g_hash_table_insert (s->loaded_infos, (gpointer) camel_message_info_uid (info), info);
 	s->flags |= CAMEL_SUMMARY_DIRTY;
@@ -2031,7 +2016,7 @@ camel_folder_summary_insert (CamelFolderSummary *s, CamelMessageInfo *info, gboo
 
 	g_hash_table_insert (s->loaded_infos, (gchar *) camel_message_info_uid (info), info);
 	if (load) {
-		g_hash_table_replace (_PRIVATE(s)->flag_cache, (gchar *)info->uid, GUINT_TO_POINTER(camel_message_info_flags(info)));
+		g_hash_table_replace (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->flag_cache, (gchar *)info->uid, GUINT_TO_POINTER(camel_message_info_flags(info)));
 	}
 
 	if (!load)
@@ -2194,7 +2179,7 @@ camel_folder_summary_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser
 	CamelMessageInfo *info = NULL;
 	gchar *buffer;
 	gsize len;
-	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
+	struct _CamelFolderSummaryPrivate *p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s);
 	off_t start;
 	CamelIndexName *name = NULL;
 
@@ -2227,7 +2212,7 @@ camel_folder_summary_info_new_from_parser(CamelFolderSummary *s, CamelMimeParser
 
 		if (name && p->index) {
 			camel_index_write_name(p->index, name);
-			camel_object_unref((CamelObject *)name);
+			camel_object_unref (name);
 			camel_mime_filter_index_set_name (
 				CAMEL_MIME_FILTER_INDEX (p->filter_index), NULL);
 		}
@@ -2254,7 +2239,7 @@ CamelMessageInfo *
 camel_folder_summary_info_new_from_message(CamelFolderSummary *s, CamelMimeMessage *msg, const gchar *bodystructure)
 {
 	CamelMessageInfo *info;
-	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
+	struct _CamelFolderSummaryPrivate *p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s);
 	CamelIndexName *name = NULL;
 
 	info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_new_from_message(s, msg, bodystructure);
@@ -2278,7 +2263,7 @@ camel_folder_summary_info_new_from_message(CamelFolderSummary *s, CamelMimeMessa
 			CamelStream *null = camel_stream_null_new();
 
 			p->filter_stream = camel_stream_filter_new (null);
-			camel_object_unref((CamelObject *)null);
+			camel_object_unref (null);
 		}
 	}
 
@@ -2286,7 +2271,7 @@ camel_folder_summary_info_new_from_message(CamelFolderSummary *s, CamelMimeMessa
 
 	if (name) {
 		camel_index_write_name(p->index, name);
-		camel_object_unref((CamelObject *)name);
+		camel_object_unref (name);
 		camel_mime_filter_index_set_name (
 			CAMEL_MIME_FILTER_INDEX (p->filter_index), NULL);
 	}
@@ -3152,23 +3137,15 @@ summary_format_string (struct _camel_header_raw *h, const gchar *name, const gch
 CamelMessageContentInfo *
 camel_folder_summary_content_info_new(CamelFolderSummary *s)
 {
+	CamelFolderSummaryClass *class;
 	CamelMessageContentInfo *ci;
 
+	class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
+
 	CAMEL_SUMMARY_LOCK(s, alloc_lock);
-#ifndef ALWAYS_ALLOC
-	if (s->content_info_chunks == NULL)
-		s->content_info_chunks = e_memchunk_new(32, s->content_info_size);
-	ci = e_memchunk_alloc(s->content_info_chunks);
-#else
-#ifndef USE_GSLICE
-	ci = g_malloc (s->content_info_size);
-#else
-	ci = g_slice_alloc (s->content_info_size);
-#endif
-#endif
+	ci = g_slice_alloc0 (class->content_info_size);
 	CAMEL_SUMMARY_UNLOCK(s, alloc_lock);
 
-	memset(ci, 0, s->content_info_size);
 	return ci;
 }
 
@@ -3594,6 +3571,7 @@ message_info_save(CamelFolderSummary *s, FILE *out, CamelMessageInfo *info)
 static void
 message_info_free(CamelFolderSummary *s, CamelMessageInfo *info)
 {
+	CamelFolderSummaryClass *class;
 	CamelMessageInfoBase *mi = (CamelMessageInfoBase *)info;
 
 	if (mi->uid) {
@@ -3615,22 +3593,11 @@ message_info_free(CamelFolderSummary *s, CamelMessageInfo *info)
 	if (mi->headers)
 		camel_header_param_list_free (mi->headers);
 
-	if (s)
-#ifndef ALWAYS_ALLOC
-		e_memchunk_free(s->message_info_chunks, mi);
-#else
-#ifndef USE_GSLICE
-		g_free(mi);
-#else
-		g_slice_free1 (s->message_info_size, mi);
-#endif
-#endif
-	else
-#ifndef USE_GSLICE
-		g_free(mi);
-#else
+	if (s) {
+		class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
+		g_slice_free1 (class->message_info_size, mi);
+	} else
 		g_slice_free (CamelMessageInfoBase, mi);
-#endif
 }
 
 static CamelMessageContentInfo *
@@ -3850,19 +3817,15 @@ content_info_save(CamelFolderSummary *s, FILE *out, CamelMessageContentInfo *ci)
 static void
 content_info_free(CamelFolderSummary *s, CamelMessageContentInfo *ci)
 {
+	CamelFolderSummaryClass *class;
+
+	class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
+
 	camel_content_type_unref(ci->type);
 	g_free(ci->id);
 	g_free(ci->description);
 	g_free(ci->encoding);
-#ifndef ALWAYS_ALLOC
-	e_memchunk_free(s->content_info_chunks, ci);
-#else
-#ifndef USE_GSLICE
-	g_free(ci);
-#else
-	g_slice_free1 (s->content_info_size, ci);
-#endif
-#endif
+	g_slice_free1 (class->content_info_size, ci);
 }
 
 static gchar *
@@ -3887,7 +3850,7 @@ summary_build_content_info(CamelFolderSummary *s, CamelMessageInfo *msginfo, Cam
 	CamelMessageContentInfo *info = NULL;
 	CamelContentType *ct;
 	gint enc_id = -1, chr_id = -1, html_id = -1, idx_id = -1;
-	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
+	struct _CamelFolderSummaryPrivate *p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s);
 	CamelMimeFilter *mfc;
 	CamelMessageContentInfo *part;
 	const gchar *calendar_header;
@@ -4049,7 +4012,7 @@ summary_build_content_info_message(CamelFolderSummary *s, CamelMessageInfo *msgi
 {
 	CamelDataWrapper *containee;
 	gint parts, i;
-	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
+	struct _CamelFolderSummaryPrivate *p = CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s);
 	CamelMessageContentInfo *info = NULL, *child;
 	CamelContentType *ct;
 	const struct _camel_header_raw *header;
@@ -4517,28 +4480,16 @@ camel_system_flag_get (guint32 flags, const gchar *name)
 gpointer
 camel_message_info_new (CamelFolderSummary *s)
 {
+	CamelFolderSummaryClass *class;
 	CamelMessageInfo *info;
 
 	if (s) {
 		CAMEL_SUMMARY_LOCK(s, alloc_lock);
-#ifndef ALWAYS_ALLOC
-		if (s->message_info_chunks == NULL)
-			s->message_info_chunks = e_memchunk_new(32, s->message_info_size);
-		info = e_memchunk_alloc0(s->message_info_chunks);
-#else
-#ifndef USE_GSLICE
-		info = g_malloc0(s->message_info_size);
-#else
-		info = g_slice_alloc0 (s->message_info_size);
-#endif
-#endif
+		class = CAMEL_FOLDER_SUMMARY_GET_CLASS (s);
+		info = g_slice_alloc0 (class->message_info_size);
 		CAMEL_SUMMARY_UNLOCK(s, alloc_lock);
 	} else {
-#ifndef USE_GSLICE
-		info = g_malloc0(sizeof(CamelMessageInfoBase));
-#else
 		info = g_slice_alloc0 (sizeof(CamelMessageInfoBase));
-#endif
 
 	}
 
@@ -4586,12 +4537,14 @@ camel_message_info_ref(gpointer o)
  * Returns: a new #CamelMessageInfo
  **/
 CamelMessageInfo *
-camel_message_info_new_from_header(CamelFolderSummary *s, struct _camel_header_raw *header)
+camel_message_info_new_from_header (CamelFolderSummary *summary,
+                                    struct _camel_header_raw *header)
 {
-	if (s)
-		return ((CamelFolderSummaryClass *)((CamelObject *)s)->klass)->message_info_new_from_header(s, header);
+	if (summary != NULL)
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (summary)->
+			message_info_new_from_header (summary, header);
 	else
-		return message_info_new_from_header(NULL, header);
+		return message_info_new_from_header (NULL, header);
 }
 
 /**
@@ -4703,7 +4656,7 @@ camel_message_info_clone(gconstpointer o)
 	const CamelMessageInfo *mi = o;
 
 	if (mi->summary)
-		return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->message_info_clone(mi->summary, mi);
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary)->message_info_clone(mi->summary, mi);
 	else
 		return message_info_clone(NULL, mi);
 }
@@ -4793,7 +4746,7 @@ gconstpointer
 camel_message_info_ptr(const CamelMessageInfo *mi, gint id)
 {
 	if (mi->summary)
-		return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_ptr(mi, id);
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary)->info_ptr(mi, id);
 	else
 		return info_ptr(mi, id);
 }
@@ -4811,7 +4764,7 @@ guint32
 camel_message_info_uint32(const CamelMessageInfo *mi, gint id)
 {
 	if (mi->summary)
-		return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_uint32(mi, id);
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary)->info_uint32(mi, id);
 	else
 		return info_uint32(mi, id);
 }
@@ -4829,7 +4782,7 @@ time_t
 camel_message_info_time(const CamelMessageInfo *mi, gint id)
 {
 	if (mi->summary)
-		return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_time(mi, id);
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary)->info_time(mi, id);
 	else
 		return info_time(mi, id);
 }
@@ -4847,7 +4800,7 @@ gboolean
 camel_message_info_user_flag(const CamelMessageInfo *mi, const gchar *id)
 {
 	if (mi->summary)
-		return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_user_flag(mi, id);
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary)->info_user_flag(mi, id);
 	else
 		return info_user_flag(mi, id);
 }
@@ -4865,7 +4818,7 @@ const gchar *
 camel_message_info_user_tag(const CamelMessageInfo *mi, const gchar *id)
 {
 	if (mi->summary)
-		return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_user_tag(mi, id);
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary)->info_user_tag(mi, id);
 	else
 		return info_user_tag(mi, id);
 }
@@ -4920,7 +4873,7 @@ info_set_flags(CamelMessageInfo *info, guint32 flags, guint32 set)
 			mi->summary->visible_count -= junk ? junk : deleted;
 	}
 	if (mi->uid)
-		g_hash_table_replace (_PRIVATE(mi->summary)->flag_cache, (gchar *)mi->uid, GUINT_TO_POINTER(mi->flags));
+		g_hash_table_replace (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(mi->summary)->flag_cache, (gchar *)mi->uid, GUINT_TO_POINTER(mi->flags));
 	if (mi->summary && mi->summary->folder && mi->uid) {
 		CamelFolderChangeInfo *changes = camel_folder_change_info_new();
 
@@ -4941,7 +4894,7 @@ info_set_flags(CamelMessageInfo *info, guint32 flags, guint32 set)
 void
 camel_folder_summary_update_flag_cache (CamelFolderSummary *s, const gchar *uid, guint32 flag)
 {
-	g_hash_table_replace (_PRIVATE(s)->flag_cache, (gchar *) uid, GUINT_TO_POINTER(flag));
+	g_hash_table_replace (CAMEL_FOLDER_SUMMARY_GET_PRIVATE(s)->flag_cache, (gchar *) uid, GUINT_TO_POINTER(flag));
 }
 
 /**
@@ -4958,7 +4911,7 @@ gboolean
 camel_message_info_set_flags(CamelMessageInfo *mi, guint32 flags, guint32 set)
 {
 	if (mi->summary)
-		return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_set_flags(mi, flags, set);
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary)->info_set_flags(mi, flags, set);
 	else
 		return info_set_flags(mi, flags, set);
 }
@@ -5000,7 +4953,7 @@ gboolean
 camel_message_info_set_user_flag(CamelMessageInfo *mi, const gchar *id, gboolean state)
 {
 	if (mi->summary)
-		return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_set_user_flag(mi, id, state);
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary)->info_set_user_flag(mi, id, state);
 	else
 		return info_set_user_flag(mi, id, state);
 }
@@ -5041,7 +4994,7 @@ gboolean
 camel_message_info_set_user_tag(CamelMessageInfo *mi, const gchar *id, const gchar *val)
 {
 	if (mi->summary)
-		return ((CamelFolderSummaryClass *)((CamelObject *)mi->summary)->klass)->info_set_user_tag(mi, id, val);
+		return CAMEL_FOLDER_SUMMARY_GET_CLASS (mi->summary)->info_set_user_tag(mi, id, val);
 	else
 		return info_set_user_tag(mi, id, val);
 }
@@ -5094,55 +5047,58 @@ camel_message_info_dump (CamelMessageInfo *mi)
 }
 
 static void
-camel_folder_summary_class_init (CamelFolderSummaryClass *klass)
+camel_folder_summary_class_init (CamelFolderSummaryClass *class)
 {
 	camel_folder_summary_parent = camel_type_get_global_classfuncs (camel_object_get_type ());
 
-	klass->summary_header_load = summary_header_load;
-	klass->summary_header_save = summary_header_save;
-
-	klass->summary_header_from_db = summary_header_from_db;
-	klass->summary_header_to_db = summary_header_to_db;
-	klass->message_info_from_db = message_info_from_db;
-	klass->message_info_to_db = message_info_to_db;
-	klass->content_info_from_db = content_info_from_db;
-	klass->content_info_to_db = content_info_to_db;
-
-	klass->message_info_new_from_header  = message_info_new_from_header;
-	klass->message_info_new_from_parser = message_info_new_from_parser;
-	klass->message_info_new_from_message = message_info_new_from_message;
-	klass->message_info_load = message_info_load;
-	klass->message_info_save = message_info_save;
-	klass->meta_message_info_save = meta_message_info_save;
-	klass->message_info_free = message_info_free;
-	klass->message_info_clone = message_info_clone;
-	klass->message_info_from_uid = message_info_from_uid;
-
-	klass->content_info_new_from_header  = content_info_new_from_header;
-	klass->content_info_new_from_parser = content_info_new_from_parser;
-	klass->content_info_new_from_message = content_info_new_from_message;
-	klass->content_info_load = content_info_load;
-	klass->content_info_save = content_info_save;
-	klass->content_info_free = content_info_free;
-
-	klass->next_uid_string = next_uid_string;
-
-	klass->info_ptr = info_ptr;
-	klass->info_uint32 = info_uint32;
-	klass->info_time = info_time;
-	klass->info_user_flag = info_user_flag;
-	klass->info_user_tag = info_user_tag;
+	class->message_info_size = sizeof (CamelMessageInfoBase);
+	class->content_info_size = sizeof (CamelMessageContentInfo);
+
+	class->summary_header_load = summary_header_load;
+	class->summary_header_save = summary_header_save;
+
+	class->summary_header_from_db = summary_header_from_db;
+	class->summary_header_to_db = summary_header_to_db;
+	class->message_info_from_db = message_info_from_db;
+	class->message_info_to_db = message_info_to_db;
+	class->content_info_from_db = content_info_from_db;
+	class->content_info_to_db = content_info_to_db;
+
+	class->message_info_new_from_header  = message_info_new_from_header;
+	class->message_info_new_from_parser = message_info_new_from_parser;
+	class->message_info_new_from_message = message_info_new_from_message;
+	class->message_info_load = message_info_load;
+	class->message_info_save = message_info_save;
+	class->meta_message_info_save = meta_message_info_save;
+	class->message_info_free = message_info_free;
+	class->message_info_clone = message_info_clone;
+	class->message_info_from_uid = message_info_from_uid;
+
+	class->content_info_new_from_header  = content_info_new_from_header;
+	class->content_info_new_from_parser = content_info_new_from_parser;
+	class->content_info_new_from_message = content_info_new_from_message;
+	class->content_info_load = content_info_load;
+	class->content_info_save = content_info_save;
+	class->content_info_free = content_info_free;
+
+	class->next_uid_string = next_uid_string;
+
+	class->info_ptr = info_ptr;
+	class->info_uint32 = info_uint32;
+	class->info_time = info_time;
+	class->info_user_flag = info_user_flag;
+	class->info_user_tag = info_user_tag;
 
 #if 0
-	klass->info_set_string = info_set_string;
-	klass->info_set_uint32 = info_set_uint32;
-	klass->info_set_time = info_set_time;
-	klass->info_set_ptr = info_set_ptr;
+	class->info_set_string = info_set_string;
+	class->info_set_uint32 = info_set_uint32;
+	class->info_set_time = info_set_time;
+	class->info_set_ptr = info_set_ptr;
 #endif
-	klass->info_set_user_flag = info_set_user_flag;
-	klass->info_set_user_tag = info_set_user_tag;
+	class->info_set_user_flag = info_set_user_flag;
+	class->info_set_user_tag = info_set_user_tag;
 
-	klass->info_set_flags = info_set_flags;
+	class->info_set_flags = info_set_flags;
 
 }
 
@@ -5154,7 +5110,7 @@ camel_folder_summary_class_init (CamelFolderSummaryClass *klass)
 void
 camel_folder_summary_set_need_preview (CamelFolderSummary *summary, gboolean preview)
 {
-	_PRIVATE(summary)->need_preview = preview;
+	CAMEL_FOLDER_SUMMARY_GET_PRIVATE(summary)->need_preview = preview;
 }
 
 /**
@@ -5165,7 +5121,7 @@ camel_folder_summary_set_need_preview (CamelFolderSummary *summary, gboolean pre
 gboolean
 camel_folder_summary_get_need_preview (CamelFolderSummary *summary)
 {
-	return _PRIVATE(summary)->need_preview;
+	return CAMEL_FOLDER_SUMMARY_GET_PRIVATE(summary)->need_preview;
 }
 
 static gboolean
diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h
index e5416b4..67db608 100644
--- a/camel/camel-folder-summary.h
+++ b/camel/camel-folder-summary.h
@@ -37,6 +37,8 @@
 #define CAMEL_FOLDER_SUMMARY(obj)         CAMEL_CHECK_CAST (obj, camel_folder_summary_get_type (), CamelFolderSummary)
 #define CAMEL_FOLDER_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_folder_summary_get_type (), CamelFolderSummaryClass)
 #define CAMEL_IS_FOLDER_SUMMARY(obj)      CAMEL_CHECK_TYPE (obj, camel_folder_summary_get_type ())
+#define CAMEL_FOLDER_SUMMARY_GET_CLASS(obj) \
+	((CamelFolderSummaryClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
@@ -231,10 +233,6 @@ struct _CamelFolderSummary {
 	guint32 junk_not_deleted_count;
 	guint32 visible_count;
 
-	/* sizes of memory objects */
-	guint32 message_info_size;
-	guint32 content_info_size;
-
 	/* memory allocators (setup automatically) */
 	struct _EMemChunk *message_info_chunks;
 	struct _EMemChunk *content_info_chunks;
@@ -264,6 +262,10 @@ struct _CamelFIRecord;
 struct _CamelFolderSummaryClass {
 	CamelObjectClass parent_class;
 
+	/* sizes of memory objects */
+	gsize message_info_size;
+	gsize content_info_size;
+
 	/* load/save the global info */
 	gint (*summary_header_load)(CamelFolderSummary *, FILE *);
 	gint (*summary_header_save)(CamelFolderSummary *, FILE *);
diff --git a/camel/camel-folder-thread.c b/camel/camel-folder-thread.c
index 61c3a83..07c7e5f 100644
--- a/camel/camel-folder-thread.c
+++ b/camel/camel-folder-thread.c
@@ -605,8 +605,7 @@ camel_folder_thread_messages_new (CamelFolder *folder, GPtrArray *uids, gboolean
 	thread->subject = thread_subject;
 	thread->tree = NULL;
 	thread->node_chunks = e_memchunk_new(32, sizeof(CamelFolderThreadNode));
-	thread->folder = folder;
-	camel_object_ref (folder);
+	thread->folder = camel_object_ref (folder);
 
 	fsummary = camel_folder_summary_array (folder->summary);
 	thread->summary = summary = g_ptr_array_new();
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index bffcb31..f1d592c 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -50,9 +50,6 @@
 
 static CamelObjectClass *parent_class = NULL;
 
-/* Returns the class for a CamelFolder */
-#define CF_CLASS(so) ((CamelFolderClass *)((CamelObject *)(so))->klass)
-
 static void camel_folder_finalize (CamelObject *object);
 
 static void refresh_info (CamelFolder *folder, CamelException *ex);
@@ -64,20 +61,20 @@ static const gchar *get_name (CamelFolder *folder);
 static const gchar *get_full_name (CamelFolder *folder);
 static CamelStore *get_parent_store   (CamelFolder *folder);
 
-static guint32 get_permanent_flags(CamelFolder *folder);
-static guint32 get_message_flags(CamelFolder *folder, const gchar *uid);
-static gboolean set_message_flags(CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set);
-static gboolean get_message_user_flag(CamelFolder *folder, const gchar *uid, const gchar *name);
-static void set_message_user_flag(CamelFolder *folder, const gchar *uid, const gchar *name, gboolean value);
-static const gchar *get_message_user_tag(CamelFolder *folder, const gchar *uid, const gchar *name);
-static void set_message_user_tag(CamelFolder *folder, const gchar *uid, const gchar *name, const gchar *value);
+static guint32 get_permanent_flags (CamelFolder *folder);
+static guint32 get_message_flags (CamelFolder *folder, const gchar *uid);
+static gboolean set_message_flags (CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set);
+static gboolean get_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name);
+static void set_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name, gboolean value);
+static const gchar *get_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name);
+static void set_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name, const gchar *value);
 
-static gint get_message_count(CamelFolder *folder);
+static gint get_message_count (CamelFolder *folder);
 
 static void expunge             (CamelFolder *folder,
 				 CamelException *ex);
-static gint folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args);
-static void folder_free(CamelObject *o, guint32 tag, gpointer val);
+static gint folder_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
+static void folder_free (CamelObject *o, guint32 tag, gpointer val);
 
 static void append_message (CamelFolder *folder, CamelMimeMessage *message,
 			    const CamelMessageInfo *info, gchar **appended_uid,
@@ -178,9 +175,9 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
 	camel_object_class->free = folder_free;
 
 	/* events */
-	camel_object_class_add_event(camel_object_class, "folder_changed", folder_changed);
-	camel_object_class_add_event(camel_object_class, "deleted", NULL);
-	camel_object_class_add_event(camel_object_class, "renamed", NULL);
+	camel_object_class_add_event (camel_object_class, "folder_changed", folder_changed);
+	camel_object_class_add_event (camel_object_class, "deleted", NULL);
+	camel_object_class_add_event (camel_object_class, "renamed", NULL);
 }
 
 static void
@@ -188,12 +185,12 @@ camel_folder_init (gpointer object, gpointer klass)
 {
 	CamelFolder *folder = object;
 
-	folder->priv = g_malloc0(sizeof(*folder->priv));
+	folder->priv = g_malloc0 (sizeof (*folder->priv));
 	folder->priv->frozen = 0;
-	folder->priv->changed_frozen = camel_folder_change_info_new();
+	folder->priv->changed_frozen = camel_folder_change_info_new ();
 	folder->priv->skip_folder_lock = FALSE;
-	g_static_rec_mutex_init(&folder->priv->lock);
-	g_static_mutex_init(&folder->priv->change_lock);
+	g_static_rec_mutex_init (&folder->priv->lock);
+	g_static_mutex_init (&folder->priv->change_lock);
 }
 
 static void
@@ -202,9 +199,9 @@ camel_folder_finalize (CamelObject *object)
 	CamelFolder *camel_folder = CAMEL_FOLDER (object);
 	struct _CamelFolderPrivate *p = camel_folder->priv;
 
-	g_free(camel_folder->name);
-	g_free(camel_folder->full_name);
-	g_free(camel_folder->description);
+	g_free (camel_folder->name);
+	g_free (camel_folder->full_name);
+	g_free (camel_folder->description);
 
 	if (camel_folder->parent_store)
 		camel_object_unref (camel_folder->parent_store);
@@ -214,12 +211,12 @@ camel_folder_finalize (CamelObject *object)
 		camel_object_unref (camel_folder->summary);
 	}
 
-	camel_folder_change_info_free(p->changed_frozen);
+	camel_folder_change_info_free (p->changed_frozen);
 
-	g_static_rec_mutex_free(&p->lock);
-	g_static_mutex_free(&p->change_lock);
+	g_static_rec_mutex_free (&p->lock);
+	g_static_mutex_free (&p->change_lock);
 
-	g_free(p);
+	g_free (p);
 }
 
 /**
@@ -258,7 +255,7 @@ camel_folder_get_type (void)
 static gchar *
 get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
 {
-	w(g_warning ("CamelFolder::get_filename not implemented for '%s'",
+	w (g_warning ("CamelFolder::get_filename not implemented for '%s'",
 		     camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
 	return g_strdup ("/dev/null");
 }
@@ -271,7 +268,7 @@ get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
 gchar *
 camel_folder_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex)
 {
-	return CF_CLASS (folder)->get_filename (folder, uid, ex);
+	return CAMEL_FOLDER_GET_CLASS (folder)->get_filename (folder, uid, ex);
 }
 
 /**
@@ -294,7 +291,7 @@ camel_folder_construct (CamelFolder *folder, CamelStore *parent_store,
 
 	folder->parent_store = parent_store;
 	if (parent_store)
-		camel_object_ref(parent_store);
+		camel_object_ref (parent_store);
 
 	folder->name = g_strdup (name);
 	folder->full_name = g_strdup (full_name);
@@ -303,7 +300,7 @@ camel_folder_construct (CamelFolder *folder, CamelStore *parent_store,
 static void
 folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
 {
-	w(g_warning ("CamelFolder::sync not implemented for '%s'",
+	w (g_warning ("CamelFolder::sync not implemented for '%s'",
 		     camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
 }
 
@@ -321,12 +318,12 @@ camel_folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CAMEL_FOLDER_REC_LOCK(folder, lock);
+	CAMEL_FOLDER_REC_LOCK (folder, lock);
 
 	if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
-		CF_CLASS (folder)->sync (folder, expunge, ex);
+		CAMEL_FOLDER_GET_CLASS (folder)->sync (folder, expunge, ex);
 
-	CAMEL_FOLDER_REC_UNLOCK(folder, lock);
+	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 }
 
 static void
@@ -348,12 +345,12 @@ camel_folder_refresh_info (CamelFolder *folder, CamelException *ex)
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
 	CAMEL_FOLDER_REC_LOCK (folder, lock);
-	CF_CLASS (folder)->refresh_info (folder, ex);
+	CAMEL_FOLDER_GET_CLASS (folder)->refresh_info (folder, ex);
 	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 }
 
 static gint
-folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
+folder_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
 {
 	CamelFolder *folder = (CamelFolder *)object;
 	gint i;
@@ -369,7 +366,7 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 			/* CamelObject args */
 		case CAMEL_OBJECT_ARG_DESCRIPTION:
 			if (folder->description == NULL)
-				folder->description = g_strdup_printf("%s", folder->full_name);
+				folder->description = g_strdup_printf ("%s", folder->full_name);
 			*arg->ca_str = folder->description;
 			break;
 
@@ -387,7 +384,7 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 			*arg->ca_int = folder->permanent_flags;
 			break;
 		case CAMEL_FOLDER_ARG_TOTAL:
-			*arg->ca_int = camel_folder_summary_count(folder->summary);
+			*arg->ca_int = camel_folder_summary_count (folder->summary);
 			break;
 		case CAMEL_FOLDER_ARG_UNREAD:
 		case CAMEL_FOLDER_ARG_DELETED:
@@ -411,7 +408,7 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 					/* count = camel_folder_summary_count (folder->summary);
 					for (j = 0; j < count; j++) {
 						if ((info = camel_folder_summary_index (folder->summary, j))) {
-							guint32 flags = camel_message_info_flags(info);
+							guint32 flags = camel_message_info_flags (info);
 
 							if ((flags & (CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
 								unread++;
@@ -424,7 +421,7 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 							}
 							if ((flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
 								visible++;
-							camel_message_info_free(info);
+							camel_message_info_free (info);
 						}
 
 					}*/
@@ -436,7 +433,7 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 						/*
 						folder->summary->junk_count = junked;
 						folder->summary->deleted_count = deleted;
-						printf("*************************** %s %d %d %d\n", folder->full_name, folder->summary->unread_count, unread, count);
+						printf ("*************************** %s %d %d %d\n", folder->full_name, folder->summary->unread_count, unread, count);
 						folder->summary->unread_count = unread; */
 					}
 				}
@@ -468,13 +465,13 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 			CamelMessageInfo *info;
 			GPtrArray *array;
 
-			count = camel_folder_summary_count(folder->summary);
-			array = g_ptr_array_new();
-			g_ptr_array_set_size(array, count);
+			count = camel_folder_summary_count (folder->summary);
+			array = g_ptr_array_new ();
+			g_ptr_array_set_size (array, count);
 			for (j=0; j<count; j++) {
-				if ((info = camel_folder_summary_index(folder->summary, j))) {
-					array->pdata[i] = g_strdup(camel_message_info_uid(info));
-					camel_message_info_free(info);
+				if ((info = camel_folder_summary_index (folder->summary, j))) {
+					array->pdata[i] = g_strdup (camel_message_info_uid (info));
+					camel_message_info_free (info);
 				}
 			}
 			*arg->ca_ptr = array;*/
@@ -482,7 +479,7 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 			g_assert (0);
 			break; }
 		case CAMEL_FOLDER_ARG_INFO_ARRAY:
-			*arg->ca_ptr = camel_folder_summary_array(folder->summary);
+			*arg->ca_ptr = camel_folder_summary_array (folder->summary);
 			break;
 		case CAMEL_FOLDER_ARG_PROPERTIES:
 			*arg->ca_ptr = NULL;
@@ -494,11 +491,11 @@ folder_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 		arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
 	}
 
-	return parent_class->getv(object, ex, args);
+	return parent_class->getv (object, ex, args);
 }
 
 static void
-folder_free(CamelObject *o, guint32 tag, gpointer val)
+folder_free (CamelObject *o, guint32 tag, gpointer val)
 {
 	CamelFolder *folder = (CamelFolder *)o;
 
@@ -508,17 +505,17 @@ folder_free(CamelObject *o, guint32 tag, gpointer val)
 		gint i;
 
 		for (i=0; i<array->len; i++)
-			g_free(array->pdata[i]);
-		g_ptr_array_free(array, TRUE);
+			g_free (array->pdata[i]);
+		g_ptr_array_free (array, TRUE);
 		break; }
 	case CAMEL_FOLDER_ARG_INFO_ARRAY:
 		camel_folder_free_summary (folder, val);
 		break;
 	case CAMEL_FOLDER_ARG_PROPERTIES:
-		g_slist_free(val);
+		g_slist_free (val);
 		break;
 	default:
-		parent_class->free(o, tag, val);
+		parent_class->free (o, tag, val);
 	}
 }
 
@@ -542,7 +539,7 @@ camel_folder_get_name (CamelFolder *folder)
 {
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
-	return CF_CLASS (folder)->get_name (folder);
+	return CAMEL_FOLDER_GET_CLASS (folder)->get_name (folder);
 }
 
 static const gchar *
@@ -564,7 +561,7 @@ camel_folder_get_full_name (CamelFolder *folder)
 {
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
-	return CF_CLASS (folder)->get_full_name (folder);
+	return CAMEL_FOLDER_GET_CLASS (folder)->get_full_name (folder);
 }
 
 static CamelStore *
@@ -584,13 +581,13 @@ camel_folder_get_parent_store (CamelFolder *folder)
 {
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
-	return CF_CLASS (folder)->get_parent_store (folder);
+	return CAMEL_FOLDER_GET_CLASS (folder)->get_parent_store (folder);
 }
 
 static void
 expunge (CamelFolder *folder, CamelException *ex)
 {
-	w(g_warning ("CamelFolder::expunge not implemented for '%s'",
+	w (g_warning ("CamelFolder::expunge not implemented for '%s'",
 		     camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
 }
 
@@ -606,20 +603,20 @@ camel_folder_expunge (CamelFolder *folder, CamelException *ex)
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CAMEL_FOLDER_REC_LOCK(folder, lock);
+	CAMEL_FOLDER_REC_LOCK (folder, lock);
 
 	if (!(folder->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
-		CF_CLASS (folder)->expunge (folder, ex);
+		CAMEL_FOLDER_GET_CLASS (folder)->expunge (folder, ex);
 
-	CAMEL_FOLDER_REC_UNLOCK(folder, lock);
+	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 }
 
 static gint
 get_message_count (CamelFolder *folder)
 {
-	g_return_val_if_fail(folder->summary != NULL, -1);
+	g_return_val_if_fail (folder->summary != NULL, -1);
 
-	return camel_folder_summary_count(folder->summary);
+	return camel_folder_summary_count (folder->summary);
 }
 
 /**
@@ -635,7 +632,7 @@ camel_folder_get_message_count (CamelFolder *folder)
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
 
-	ret = CF_CLASS (folder)->get_message_count (folder);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->get_message_count (folder);
 
 	return ret;
 }
@@ -656,7 +653,7 @@ camel_folder_get_unread_message_count (CamelFolder *folder)
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
 
-	camel_object_get(folder, NULL, CAMEL_FOLDER_UNREAD, &count, 0);
+	camel_object_get (folder, NULL, CAMEL_FOLDER_UNREAD, &count, 0);
 
 	return count;
 }
@@ -675,7 +672,7 @@ camel_folder_get_deleted_message_count (CamelFolder *folder)
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), -1);
 
-	camel_object_get(folder, NULL, CAMEL_FOLDER_DELETED, &count, 0);
+	camel_object_get (folder, NULL, CAMEL_FOLDER_DELETED, &count, 0);
 
 	return count;
 }
@@ -689,7 +686,7 @@ append_message (CamelFolder *folder, CamelMimeMessage *message,
 			      _("Unsupported operation: append message: for %s"),
 			      camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
 
-	w(g_warning ("CamelFolder::append_message not implemented for '%s'",
+	w (g_warning ("CamelFolder::append_message not implemented for '%s'",
 		     camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
 
 	return;
@@ -716,9 +713,9 @@ camel_folder_append_message (CamelFolder *folder, CamelMimeMessage *message,
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CAMEL_FOLDER_REC_LOCK(folder, lock);
-	CF_CLASS (folder)->append_message (folder, message, info, appended_uid, ex);
-	CAMEL_FOLDER_REC_UNLOCK(folder, lock);
+	CAMEL_FOLDER_REC_LOCK (folder, lock);
+	CAMEL_FOLDER_GET_CLASS (folder)->append_message (folder, message, info, appended_uid, ex);
+	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 }
 
 static guint32
@@ -740,23 +737,23 @@ camel_folder_get_permanent_flags (CamelFolder *folder)
 {
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
 
-	return CF_CLASS (folder)->get_permanent_flags (folder);
+	return CAMEL_FOLDER_GET_CLASS (folder)->get_permanent_flags (folder);
 }
 
 static guint32
-get_message_flags(CamelFolder *folder, const gchar *uid)
+get_message_flags (CamelFolder *folder, const gchar *uid)
 {
 	CamelMessageInfo *info;
 	guint32 flags;
 
-	g_return_val_if_fail(folder->summary != NULL, 0);
+	g_return_val_if_fail (folder->summary != NULL, 0);
 
-	info = camel_folder_summary_uid(folder->summary, uid);
+	info = camel_folder_summary_uid (folder->summary, uid);
 	if (info == NULL)
 		return 0;
 
-	flags = camel_message_info_flags(info);
-	camel_message_info_free(info);
+	flags = camel_message_info_flags (info);
+	camel_message_info_free (info);
 
 	return flags;
 }
@@ -778,25 +775,25 @@ camel_folder_get_message_flags (CamelFolder *folder, const gchar *uid)
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
 
-	ret = CF_CLASS (folder)->get_message_flags (folder, uid);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->get_message_flags (folder, uid);
 
 	return ret;
 }
 
 static gboolean
-set_message_flags(CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set)
+set_message_flags (CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set)
 {
 	CamelMessageInfo *info;
 	gint res;
 
-	g_return_val_if_fail(folder->summary != NULL, FALSE);
+	g_return_val_if_fail (folder->summary != NULL, FALSE);
 
-	info = camel_folder_summary_uid(folder->summary, uid);
+	info = camel_folder_summary_uid (folder->summary, uid);
 	if (info == NULL)
 		return FALSE;
 
-	res = camel_message_info_set_flags(info, flags, set);
-	camel_message_info_free(info);
+	res = camel_message_info_set_flags (info, flags, set);
+	camel_message_info_free (info);
 
 	return res;
 }
@@ -813,7 +810,7 @@ set_message_flags(CamelFolder *folder, const gchar *uid, guint32 flags, guint32
  * folder or store is closed. See #camel_folder_get_permanent_flags)
  *
  * E.g. to set the deleted flag and clear the draft flag, use
- * #camel_folder_set_message_flags(folder, uid, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_DRAFT, CAMEL_MESSAGE_DELETED);
+ * #camel_folder_set_message_flags (folder, uid, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_DRAFT, CAMEL_MESSAGE_DELETED);
  *
  * DEPRECATED: Use #camel_message_info_set_flags on the message info directly
  * (when it works)
@@ -821,32 +818,32 @@ set_message_flags(CamelFolder *folder, const gchar *uid, guint32 flags, guint32
  * Returns: %TRUE if the flags were changed or %FALSE otherwise
  **/
 gboolean
-camel_folder_set_message_flags(CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set)
+camel_folder_set_message_flags (CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set)
 {
-	g_return_val_if_fail(CAMEL_IS_FOLDER(folder), FALSE);
+	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
 
 	if ((flags & (CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK_LEARN)) == CAMEL_MESSAGE_JUNK) {
 		flags |= CAMEL_MESSAGE_JUNK_LEARN;
 		set &= ~CAMEL_MESSAGE_JUNK_LEARN;
 	}
 
-	return CF_CLASS(folder)->set_message_flags(folder, uid, flags, set);
+	return CAMEL_FOLDER_GET_CLASS (folder)->set_message_flags (folder, uid, flags, set);
 }
 
 static gboolean
-get_message_user_flag(CamelFolder *folder, const gchar *uid, const gchar *name)
+get_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name)
 {
 	CamelMessageInfo *info;
 	gboolean ret;
 
-	g_return_val_if_fail(folder->summary != NULL, FALSE);
+	g_return_val_if_fail (folder->summary != NULL, FALSE);
 
-	info = camel_folder_summary_uid(folder->summary, uid);
+	info = camel_folder_summary_uid (folder->summary, uid);
 	if (info == NULL)
 		return FALSE;
 
-	ret = camel_message_info_user_flag(info, name);
-	camel_message_info_free(info);
+	ret = camel_message_info_user_flag (info, name);
+	camel_message_info_free (info);
 
 	return ret;
 }
@@ -871,24 +868,24 @@ camel_folder_get_message_user_flag (CamelFolder *folder, const gchar *uid,
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
 
-	ret = CF_CLASS (folder)->get_message_user_flag (folder, uid, name);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->get_message_user_flag (folder, uid, name);
 
 	return ret;
 }
 
 static void
-set_message_user_flag(CamelFolder *folder, const gchar *uid, const gchar *name, gboolean value)
+set_message_user_flag (CamelFolder *folder, const gchar *uid, const gchar *name, gboolean value)
 {
 	CamelMessageInfo *info;
 
-	g_return_if_fail(folder->summary != NULL);
+	g_return_if_fail (folder->summary != NULL);
 
-	info = camel_folder_summary_uid(folder->summary, uid);
+	info = camel_folder_summary_uid (folder->summary, uid);
 	if (info == NULL)
 		return;
 
-	camel_message_info_set_user_flag(info, name, value);
-	camel_message_info_free(info);
+	camel_message_info_set_user_flag (info, name, value);
+	camel_message_info_free (info);
 }
 
 /**
@@ -911,23 +908,23 @@ camel_folder_set_message_user_flag (CamelFolder *folder, const gchar *uid,
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CF_CLASS (folder)->set_message_user_flag (folder, uid, name, value);
+	CAMEL_FOLDER_GET_CLASS (folder)->set_message_user_flag (folder, uid, name, value);
 }
 
 static const gchar *
-get_message_user_tag(CamelFolder *folder, const gchar *uid, const gchar *name)
+get_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name)
 {
 	CamelMessageInfo *info;
 	const gchar *ret;
 
-	g_return_val_if_fail(folder->summary != NULL, NULL);
+	g_return_val_if_fail (folder->summary != NULL, NULL);
 
-	info = camel_folder_summary_uid(folder->summary, uid);
+	info = camel_folder_summary_uid (folder->summary, uid);
 	if (info == NULL)
 		return NULL;
 
-	ret = camel_message_info_user_tag(info, name);
-	camel_message_info_free(info);
+	ret = camel_message_info_user_tag (info, name);
+	camel_message_info_free (info);
 
 	return ret;
 }
@@ -951,24 +948,24 @@ camel_folder_get_message_user_tag (CamelFolder *folder, const gchar *uid,  const
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
 	/* FIXME: should duplicate string */
-	ret = CF_CLASS (folder)->get_message_user_tag (folder, uid, name);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->get_message_user_tag (folder, uid, name);
 
 	return ret;
 }
 
 static void
-set_message_user_tag(CamelFolder *folder, const gchar *uid, const gchar *name, const gchar *value)
+set_message_user_tag (CamelFolder *folder, const gchar *uid, const gchar *name, const gchar *value)
 {
 	CamelMessageInfo *info;
 
-	g_return_if_fail(folder->summary != NULL);
+	g_return_if_fail (folder->summary != NULL);
 
-	info = camel_folder_summary_uid(folder->summary, uid);
+	info = camel_folder_summary_uid (folder->summary, uid);
 	if (info == NULL)
 		return;
 
-	camel_message_info_set_user_tag(info, name, value);
-	camel_message_info_free(info);
+	camel_message_info_set_user_tag (info, name, value);
+	camel_message_info_free (info);
 }
 
 /**
@@ -990,15 +987,15 @@ camel_folder_set_message_user_tag (CamelFolder *folder, const gchar *uid, const
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CF_CLASS (folder)->set_message_user_tag (folder, uid, name, value);
+	CAMEL_FOLDER_GET_CLASS (folder)->set_message_user_tag (folder, uid, name, value);
 }
 
 static CamelMessageInfo *
 get_message_info (CamelFolder *folder, const gchar *uid)
 {
-	g_return_val_if_fail(folder->summary != NULL, NULL);
+	g_return_val_if_fail (folder->summary != NULL, NULL);
 
-	return camel_folder_summary_uid(folder->summary, uid);
+	return camel_folder_summary_uid (folder->summary, uid);
 }
 
 /**
@@ -1020,7 +1017,7 @@ camel_folder_get_message_info (CamelFolder *folder, const gchar *uid)
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 	g_return_val_if_fail (uid != NULL, NULL);
 
-	ret = CF_CLASS (folder)->get_message_info (folder, uid);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->get_message_info (folder, uid);
 
 	return ret;
 }
@@ -1028,9 +1025,9 @@ camel_folder_get_message_info (CamelFolder *folder, const gchar *uid)
 static void
 free_message_info (CamelFolder *folder, CamelMessageInfo *info)
 {
-	g_return_if_fail(folder->summary != NULL);
+	g_return_if_fail (folder->summary != NULL);
 
-	camel_message_info_free(info);
+	camel_message_info_free (info);
 }
 
 /**
@@ -1042,20 +1039,20 @@ free_message_info (CamelFolder *folder, CamelMessageInfo *info)
  * #camel_folder_get_message_info.
  **/
 void
-camel_folder_free_message_info(CamelFolder *folder, CamelMessageInfo *info)
+camel_folder_free_message_info (CamelFolder *folder, CamelMessageInfo *info)
 {
-	g_return_if_fail(CAMEL_IS_FOLDER (folder));
-	g_return_if_fail(info != NULL);
+	g_return_if_fail (CAMEL_IS_FOLDER (folder));
+	g_return_if_fail (info != NULL);
 
-	CF_CLASS (folder)->free_message_info(folder, info);
+	CAMEL_FOLDER_GET_CLASS (folder)->free_message_info (folder, info);
 }
 
 static void
 ref_message_info (CamelFolder *folder, CamelMessageInfo *info)
 {
-	g_return_if_fail(folder->summary != NULL);
+	g_return_if_fail (folder->summary != NULL);
 
-	camel_message_info_ref(info);
+	camel_message_info_ref (info);
 }
 
 /**
@@ -1069,12 +1066,12 @@ ref_message_info (CamelFolder *folder, CamelMessageInfo *info)
  * #camel_folder_get_message_info.
  **/
 void
-camel_folder_ref_message_info(CamelFolder *folder, CamelMessageInfo *info)
+camel_folder_ref_message_info (CamelFolder *folder, CamelMessageInfo *info)
 {
-	g_return_if_fail(CAMEL_IS_FOLDER (folder));
-	g_return_if_fail(info != NULL);
+	g_return_if_fail (CAMEL_IS_FOLDER (folder));
+	g_return_if_fail (info != NULL);
 
-	CF_CLASS (folder)->ref_message_info(folder, info);
+	CAMEL_FOLDER_GET_CLASS (folder)->ref_message_info (folder, info);
 }
 
 /* TODO: is this function required anyway? */
@@ -1099,7 +1096,7 @@ camel_folder_has_summary_capability (CamelFolder *folder)
 static CamelMimeMessage *
 get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
 {
-	w(g_warning ("CamelFolder::get_message not implemented for '%s'",
+	w (g_warning ("CamelFolder::get_message not implemented for '%s'",
 		     camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
 
 	return NULL;
@@ -1122,16 +1119,16 @@ camel_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
-	CAMEL_FOLDER_REC_LOCK(folder, lock);
+	CAMEL_FOLDER_REC_LOCK (folder, lock);
 
-	ret = CF_CLASS (folder)->get_message (folder, uid, ex);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->get_message (folder, uid, ex);
 
-	CAMEL_FOLDER_REC_UNLOCK(folder, lock);
+	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 
-	if (ret && camel_debug_start(":folder")) {
-		printf("CamelFolder:get_message('%s', '%s') =\n", folder->full_name, uid);
-		camel_mime_message_dump(ret, FALSE);
-		camel_debug_end();
+	if (ret && camel_debug_start (":folder")) {
+		printf ("CamelFolder:get_message ('%s', '%s') =\n", folder->full_name, uid);
+		camel_mime_message_dump (ret, FALSE);
+		camel_debug_end ();
 	}
 
 	return ret;
@@ -1152,24 +1149,24 @@ void
 camel_folder_sync_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
-	CAMEL_FOLDER_REC_LOCK(folder, lock);
+	CAMEL_FOLDER_REC_LOCK (folder, lock);
 
 	/* Use the sync_message method if the class implements it. */
-	if (CF_CLASS (folder)->sync_message)
-		CF_CLASS (folder)->sync_message (folder, uid, ex);
+	if (CAMEL_FOLDER_GET_CLASS (folder)->sync_message)
+		CAMEL_FOLDER_GET_CLASS (folder)->sync_message (folder, uid, ex);
 	else {
 		CamelMimeMessage *message;
-		message = CF_CLASS (folder)->get_message (folder, uid, ex);
+		message = CAMEL_FOLDER_GET_CLASS (folder)->get_message (folder, uid, ex);
 		if (message)
-			  camel_object_unref(message);
+			  camel_object_unref (message);
 	}
-	CAMEL_FOLDER_REC_UNLOCK(folder, lock);
+	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 }
 
 static GPtrArray *
-get_uids(CamelFolder *folder)
+get_uids (CamelFolder *folder)
 {
-	g_return_val_if_fail(folder->summary != NULL, g_ptr_array_new ());
+	g_return_val_if_fail (folder->summary != NULL, g_ptr_array_new ());
 
 	return camel_folder_summary_array (folder->summary);
 }
@@ -1193,7 +1190,7 @@ camel_folder_get_uids (CamelFolder *folder)
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
-	ret = CF_CLASS (folder)->get_uids (folder);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->get_uids (folder);
 
 	return ret;
 }
@@ -1204,8 +1201,8 @@ free_uids (CamelFolder *folder, GPtrArray *array)
 	gint i;
 
 	for (i=0; i<array->len; i++)
-		camel_pstring_free(array->pdata[i]);
-	g_ptr_array_free(array, TRUE);
+		camel_pstring_free (array->pdata[i]);
+	g_ptr_array_free (array, TRUE);
 }
 
 /**
@@ -1220,7 +1217,7 @@ camel_folder_free_uids (CamelFolder *folder, GPtrArray *array)
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CF_CLASS (folder)->free_uids (folder, array);
+	CAMEL_FOLDER_GET_CLASS (folder)->free_uids (folder, array);
 }
 
 /**
@@ -1232,11 +1229,11 @@ get_uncached_uids (CamelFolder *folder, GPtrArray * uids, CamelException *ex)
 	GPtrArray *result;
 	gint i;
 
-	result = g_ptr_array_new();
+	result = g_ptr_array_new ();
 
-	g_ptr_array_set_size(result, uids->len);
+	g_ptr_array_set_size (result, uids->len);
 	for (i = 0; i < uids->len; i++)
-	    result->pdata[i] = (gchar *)camel_pstring_strdup(uids->pdata[i]);
+	    result->pdata[i] = (gchar *)camel_pstring_strdup (uids->pdata[i]);
 	return result;
 }
 
@@ -1256,7 +1253,7 @@ GPtrArray *
 camel_folder_get_uncached_uids (CamelFolder *folder, GPtrArray * uids, CamelException *ex)
 {
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
-	return CF_CLASS (folder)->get_uncached_uids(folder, uids, ex);
+	return CAMEL_FOLDER_GET_CLASS (folder)->get_uncached_uids (folder, uids, ex);
 }
 
 static gint
@@ -1288,7 +1285,7 @@ camel_folder_cmp_uids (CamelFolder *folder, const gchar *uid1, const gchar *uid2
 	g_return_val_if_fail (uid1 != NULL, 0);
 	g_return_val_if_fail (uid2 != NULL, 0);
 
-	return CF_CLASS (folder)->cmp_uids (folder, uid1, uid2);
+	return CAMEL_FOLDER_GET_CLASS (folder)->cmp_uids (folder, uid1, uid2);
 }
 
 static gint
@@ -1323,15 +1320,15 @@ camel_folder_sort_uids (CamelFolder *folder, GPtrArray *uids)
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CF_CLASS (folder)->sort_uids (folder, uids);
+	CAMEL_FOLDER_GET_CLASS (folder)->sort_uids (folder, uids);
 }
 
 static GPtrArray *
-get_summary(CamelFolder *folder)
+get_summary (CamelFolder *folder)
 {
-	g_assert(folder->summary != NULL);
+	g_assert (folder->summary != NULL);
 
-	return camel_folder_summary_array(folder->summary);
+	return camel_folder_summary_array (folder->summary);
 }
 
 /**
@@ -1351,13 +1348,13 @@ camel_folder_get_summary (CamelFolder *folder)
 
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
-	ret = CF_CLASS (folder)->get_summary (folder);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->get_summary (folder);
 
 	return ret;
 }
 
 static void
-free_summary(CamelFolder *folder, GPtrArray *summary)
+free_summary (CamelFolder *folder, GPtrArray *summary)
 {
 	g_ptr_array_foreach (summary, (GFunc) camel_pstring_free, NULL);
 	g_ptr_array_free (summary, TRUE);
@@ -1371,9 +1368,9 @@ free_summary(CamelFolder *folder, GPtrArray *summary)
  * Frees the summary array returned by #camel_folder_get_summary.
  **/
 void
-camel_folder_free_summary(CamelFolder *folder, GPtrArray *array)
+camel_folder_free_summary (CamelFolder *folder, GPtrArray *array)
 {
-	CF_CLASS(folder)->free_summary(folder, array);
+	CAMEL_FOLDER_GET_CLASS (folder)->free_summary (folder, array);
 }
 
 /**
@@ -1400,7 +1397,7 @@ search_by_expression (CamelFolder *folder, const gchar *expression,
 			      _("Unsupported operation: search by expression: for %s"),
 			      camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
 
-	w(g_warning ("CamelFolder::search_by_expression not implemented for "
+	w (g_warning ("CamelFolder::search_by_expression not implemented for "
 		     "'%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
 
 	return NULL;
@@ -1428,7 +1425,7 @@ camel_folder_search_by_expression (CamelFolder *folder, const gchar *expression,
 
 	/* NOTE: that it is upto the callee to lock */
 
-	ret = CF_CLASS (folder)->search_by_expression (folder, expression, ex);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->search_by_expression (folder, expression, ex);
 
 	return ret;
 }
@@ -1441,7 +1438,7 @@ count_by_expression (CamelFolder *folder, const gchar *expression,
 			      _("Unsupported operation: count by expression: for %s"),
 			      camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
 
-	w(g_warning ("CamelFolder::count_by_expression not implemented for "
+	w (g_warning ("CamelFolder::count_by_expression not implemented for "
 		     "'%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
 
 	return 0;
@@ -1470,19 +1467,19 @@ camel_folder_count_by_expression (CamelFolder *folder, const gchar *expression,
 
 	/* NOTE: that it is upto the callee to lock */
 
-	ret = CF_CLASS (folder)->count_by_expression (folder, expression, ex);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->count_by_expression (folder, expression, ex);
 
 	return ret;
 }
 
 static GPtrArray *
-search_by_uids(CamelFolder *folder, const gchar *exp, GPtrArray *uids, CamelException *ex)
+search_by_uids (CamelFolder *folder, const gchar *exp, GPtrArray *uids, CamelException *ex)
 {
 	camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
 			      _("Unsupported operation: search by UIDs: for %s"),
 			      camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder)));
 
-	w(g_warning ("CamelFolder::search_by_expression not implemented for "
+	w (g_warning ("CamelFolder::search_by_expression not implemented for "
 		     "'%s'", camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
 
 	return NULL;
@@ -1501,16 +1498,16 @@ search_by_uids(CamelFolder *folder, const gchar *exp, GPtrArray *uids, CamelExce
  * free the list and each of the elements when it is done.
  **/
 GPtrArray *
-camel_folder_search_by_uids(CamelFolder *folder, const gchar *expr, GPtrArray *uids, CamelException *ex)
+camel_folder_search_by_uids (CamelFolder *folder, const gchar *expr, GPtrArray *uids, CamelException *ex)
 {
 	GPtrArray *ret;
 
-	g_return_val_if_fail(CAMEL_IS_FOLDER (folder), NULL);
-	g_return_val_if_fail(folder->folder_flags & CAMEL_FOLDER_HAS_SEARCH_CAPABILITY, NULL);
+	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
+	g_return_val_if_fail (folder->folder_flags & CAMEL_FOLDER_HAS_SEARCH_CAPABILITY, NULL);
 
 	/* NOTE: that it is upto the callee to lock */
 
-	ret = CF_CLASS(folder)->search_by_uids(folder, expr, uids, ex);
+	ret = CAMEL_FOLDER_GET_CLASS (folder)->search_by_uids (folder, expr, uids, ex);
 
 	return ret;
 }
@@ -1539,7 +1536,7 @@ camel_folder_search_free (CamelFolder *folder, GPtrArray *result)
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
 	/* NOTE: upto the callee to lock */
-	CF_CLASS (folder)->search_free (folder, result);
+	CAMEL_FOLDER_GET_CLASS (folder)->search_free (folder, result);
 }
 
 static void
@@ -1552,20 +1549,20 @@ transfer_message_to (CamelFolder *source, const gchar *uid, CamelFolder *dest,
 
 	/* Default implementation. */
 
-	msg = camel_folder_get_message(source, uid, ex);
+	msg = camel_folder_get_message (source, uid, ex);
 	if (!msg)
 		return;
 
 	/* if its deleted we poke the flags, so we need to copy the messageinfo */
 	if ((source->folder_flags & CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY)
-			&& (minfo = camel_folder_get_message_info(source, uid))) {
-		info = camel_message_info_clone(minfo);
-		camel_folder_free_message_info(source, minfo);
+			&& (minfo = camel_folder_get_message_info (source, uid))) {
+		info = camel_message_info_clone (minfo);
+		camel_folder_free_message_info (source, minfo);
 	} else
-		info = camel_message_info_new_from_header(NULL, ((CamelMimePart *)msg)->headers);
+		info = camel_message_info_new_from_header (NULL, ((CamelMimePart *)msg)->headers);
 
 	/* we don't want to retain the deleted flag */
-	camel_message_info_set_flags(info, CAMEL_MESSAGE_DELETED, 0);
+	camel_message_info_set_flags (info, CAMEL_MESSAGE_DELETED, 0);
 
 	camel_folder_append_message (dest, msg, info, transferred_uid, ex);
 	camel_object_unref (msg);
@@ -1588,31 +1585,31 @@ transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, G
 		g_ptr_array_set_size (*transferred_uids, uids->len);
 	}
 
-	camel_exception_init(&local);
+	camel_exception_init (&local);
 	if (ex == NULL)
 		ex = &local;
 
-	camel_operation_start(NULL, delete_originals ? _("Moving messages") : _("Copying messages"));
+	camel_operation_start (NULL, delete_originals ? _("Moving messages") : _("Copying messages"));
 
 	if (uids->len > 1) {
-		camel_folder_freeze(dest);
+		camel_folder_freeze (dest);
 		if (delete_originals)
-			camel_folder_freeze(source);
+			camel_folder_freeze (source);
 	}
 	for (i = 0; i < uids->len && !camel_exception_is_set (ex); i++) {
 		if (transferred_uids)
 			ret_uid = (gchar **)&((*transferred_uids)->pdata[i]);
 		transfer_message_to (source, uids->pdata[i], dest, ret_uid, delete_originals, ex);
-		camel_operation_progress(NULL, i * 100 / uids->len);
+		camel_operation_progress (NULL, i * 100 / uids->len);
 	}
 	if (uids->len > 1) {
-		camel_folder_thaw(dest);
+		camel_folder_thaw (dest);
 		if (delete_originals)
-			camel_folder_thaw(source);
+			camel_folder_thaw (source);
 	}
 
-	camel_operation_end(NULL);
-	camel_exception_clear(&local);
+	camel_operation_end (NULL);
+	camel_exception_clear (&local);
 }
 
 /**
@@ -1648,9 +1645,9 @@ camel_folder_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
 		 * vtrash transfer method.
 		 */
 		if (CAMEL_IS_VTRASH_FOLDER (dest))
-			CF_CLASS (dest)->transfer_messages_to (source, uids, dest, transferred_uids, delete_originals, ex);
+			CAMEL_FOLDER_GET_CLASS (dest)->transfer_messages_to (source, uids, dest, transferred_uids, delete_originals, ex);
 		else
-			CF_CLASS (source)->transfer_messages_to (source, uids, dest, transferred_uids, delete_originals, ex);
+			CAMEL_FOLDER_GET_CLASS (source)->transfer_messages_to (source, uids, dest, transferred_uids, delete_originals, ex);
 	} else
 		transfer_messages_to (source, uids, dest, transferred_uids, delete_originals, ex);
 }
@@ -1681,7 +1678,7 @@ camel_folder_delete (CamelFolder *folder)
 
 	folder->folder_flags |= CAMEL_FOLDER_HAS_BEEN_DELETED;
 
-	CF_CLASS (folder)->delete (folder);
+	CAMEL_FOLDER_GET_CLASS (folder)->delete (folder);
 
 	CAMEL_FOLDER_REC_UNLOCK (folder, lock);
 
@@ -1696,13 +1693,13 @@ folder_rename (CamelFolder *folder, const gchar *new)
 {
 	gchar *tmp;
 
-	d(printf("CamelFolder:rename('%s')\n", new));
+	d (printf ("CamelFolder:rename ('%s')\n", new));
 
-	g_free(folder->full_name);
-	folder->full_name = g_strdup(new);
-	g_free(folder->name);
-	tmp = strrchr(new, '/');
-	folder->name = g_strdup(tmp?tmp+1:new);
+	g_free (folder->full_name);
+	folder->full_name = g_strdup (new);
+	g_free (folder->name);
+	tmp = strrchr (new, '/');
+	folder->name = g_strdup (tmp?tmp+1:new);
 }
 
 /**
@@ -1716,29 +1713,29 @@ folder_rename (CamelFolder *folder, const gchar *new)
  * is performed on the folder.
  **/
 void
-camel_folder_rename(CamelFolder *folder, const gchar *new)
+camel_folder_rename (CamelFolder *folder, const gchar *new)
 {
 	gchar *old;
 
-	old = g_strdup(folder->full_name);
+	old = g_strdup (folder->full_name);
 
-	CF_CLASS (folder)->rename(folder, new);
+	CAMEL_FOLDER_GET_CLASS (folder)->rename (folder, new);
 	camel_db_rename_folder (folder->parent_store->cdb_w, old, new, NULL);
 	camel_object_trigger_event (folder, "renamed", old);
-	g_free(old);
+	g_free (old);
 }
 
 static void
 freeze (CamelFolder *folder)
 {
-	CAMEL_FOLDER_LOCK(folder, change_lock);
+	CAMEL_FOLDER_LOCK (folder, change_lock);
 
-	g_assert(folder->priv->frozen >= 0);
+	g_assert (folder->priv->frozen >= 0);
 
 	folder->priv->frozen++;
 
-	d(printf ("freeze(%p '%s') = %d\n", folder, folder->full_name, folder->priv->frozen));
-	CAMEL_FOLDER_UNLOCK(folder, change_lock);
+	d (printf ("freeze (%p '%s') = %d\n", folder, folder->full_name, folder->priv->frozen));
+	CAMEL_FOLDER_UNLOCK (folder, change_lock);
 }
 
 /**
@@ -1755,7 +1752,7 @@ camel_folder_freeze (CamelFolder * folder)
 {
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 
-	CF_CLASS (folder)->freeze (folder);
+	CAMEL_FOLDER_GET_CLASS (folder)->freeze (folder);
 }
 
 static void
@@ -1763,25 +1760,25 @@ thaw (CamelFolder * folder)
 {
 	CamelFolderChangeInfo *info = NULL;
 
-	CAMEL_FOLDER_LOCK(folder, change_lock);
+	CAMEL_FOLDER_LOCK (folder, change_lock);
 
-	g_assert(folder->priv->frozen > 0);
+	g_assert (folder->priv->frozen > 0);
 
 	folder->priv->frozen--;
 
-	d(printf ("thaw(%p '%s') = %d\n", folder, folder->full_name, folder->priv->frozen));
+	d (printf ("thaw (%p '%s') = %d\n", folder, folder->full_name, folder->priv->frozen));
 
 	if (folder->priv->frozen == 0
-	    && camel_folder_change_info_changed(folder->priv->changed_frozen)) {
+	    && camel_folder_change_info_changed (folder->priv->changed_frozen)) {
 		info = folder->priv->changed_frozen;
-		folder->priv->changed_frozen = camel_folder_change_info_new();
+		folder->priv->changed_frozen = camel_folder_change_info_new ();
 	}
 
-	CAMEL_FOLDER_UNLOCK(folder, change_lock);
+	CAMEL_FOLDER_UNLOCK (folder, change_lock);
 
 	if (info) {
 		camel_object_trigger_event (folder, "folder_changed", info);
-		camel_folder_change_info_free(info);
+		camel_folder_change_info_free (info);
 	}
 }
 
@@ -1798,7 +1795,7 @@ camel_folder_thaw (CamelFolder *folder)
 	g_return_if_fail (CAMEL_IS_FOLDER (folder));
 	g_return_if_fail (folder->priv->frozen != 0);
 
-	CF_CLASS (folder)->thaw (folder);
+	CAMEL_FOLDER_GET_CLASS (folder)->thaw (folder);
 }
 
 static gboolean
@@ -1818,7 +1815,7 @@ camel_folder_is_frozen (CamelFolder *folder)
 {
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
 
-	return CF_CLASS (folder)->is_frozen (folder);
+	return CAMEL_FOLDER_GET_CLASS (folder)->is_frozen (folder);
 }
 
 static CamelFolderQuotaInfo *
@@ -1831,7 +1828,7 @@ get_quota_info (CamelFolder *folder)
  * camel_folder_get_quota_info:
  * @folder: a #CamelFolder object
  *
- * Returns: list of known quota(s) for the folder.
+ * Returns: list of known quota (s) for the folder.
  *
  * Since: 2.24
  **/
@@ -1840,7 +1837,7 @@ camel_folder_get_quota_info (CamelFolder *folder)
 {
 	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
 
-	return CF_CLASS (folder)->get_quota_info (folder);
+	return CAMEL_FOLDER_GET_CLASS (folder)->get_quota_info (folder);
 }
 
 /**
@@ -1930,7 +1927,7 @@ struct _folder_filter_msg {
 };
 
 static void
-filter_filter(CamelSession *session, CamelSessionThreadMsg *tmsg)
+filter_filter (CamelSession *session, CamelSessionThreadMsg *tmsg)
 {
 	struct _folder_filter_msg *m = (struct _folder_filter_msg *) tmsg;
 	CamelMessageInfo *info;
@@ -1945,11 +1942,11 @@ filter_filter(CamelSession *session, CamelSessionThreadMsg *tmsg)
 		camel_operation_start (NULL, ngettext ("Learning new spam message in '%s'", "Learning new spam messages in '%s'", m->junk->len), m->folder->full_name);
 
 		for (i = 0; i < m->junk->len; i ++) {
-			CamelMimeMessage *msg = camel_folder_get_message(m->folder, m->junk->pdata[i], &ex);
+			CamelMimeMessage *msg = camel_folder_get_message (m->folder, m->junk->pdata[i], &ex);
 			gint pc = 100 * i / m->junk->len;
 
 			camel_exception_clear (&ex);
-			camel_operation_progress(NULL, pc);
+			camel_operation_progress (NULL, pc);
 
 			if (msg) {
 				camel_junk_plugin_report_junk (csp, msg);
@@ -1963,11 +1960,11 @@ filter_filter(CamelSession *session, CamelSessionThreadMsg *tmsg)
 		/* Translators: The %s is replaced with a folder name where the operation is running. */
 		camel_operation_start (NULL, ngettext ("Learning new ham message in '%s'", "Learning new ham messages in '%s'", m->notjunk->len), m->folder->full_name);
 		for (i = 0; i < m->notjunk->len; i ++) {
-			CamelMimeMessage *msg = camel_folder_get_message(m->folder, m->notjunk->pdata[i], &ex);
+			CamelMimeMessage *msg = camel_folder_get_message (m->folder, m->notjunk->pdata[i], &ex);
 			gint pc = 100 * i / m->notjunk->len;
 
 			camel_exception_clear (&ex);
-			camel_operation_progress(NULL, pc);
+			camel_operation_progress (NULL, pc);
 
 			if (msg) {
 				camel_junk_plugin_report_notjunk (csp, msg);
@@ -1982,65 +1979,65 @@ filter_filter(CamelSession *session, CamelSessionThreadMsg *tmsg)
 
 	if (m->driver && m->recents) {
 		/* Translators: The %s is replaced with a folder name where the operation is running. */
-		camel_operation_start(NULL, ngettext ("Filtering new message in '%s'", "Filtering new messages in '%s'", m->recents->len), m->folder->full_name);
+		camel_operation_start (NULL, ngettext ("Filtering new message in '%s'", "Filtering new messages in '%s'", m->recents->len), m->folder->full_name);
 
-		source_url = camel_service_get_url((CamelService *)m->folder->parent_store);
-		uri = camel_url_new(source_url, NULL);
-		g_free(source_url);
+		source_url = camel_service_get_url ((CamelService *)m->folder->parent_store);
+		uri = camel_url_new (source_url, NULL);
+		g_free (source_url);
 		if (m->folder->full_name && m->folder->full_name[0] != '/') {
-			gchar *tmp = alloca(strlen(m->folder->full_name)+2);
+			gchar *tmp = alloca (strlen (m->folder->full_name)+2);
 
-			sprintf(tmp, "/%s", m->folder->full_name);
-			camel_url_set_path(uri, tmp);
+			sprintf (tmp, "/%s", m->folder->full_name);
+			camel_url_set_path (uri, tmp);
 		} else
-			camel_url_set_path(uri, m->folder->full_name);
-		source_url = camel_url_to_string(uri, CAMEL_URL_HIDE_ALL);
-		camel_url_free(uri);
+			camel_url_set_path (uri, m->folder->full_name);
+		source_url = camel_url_to_string (uri, CAMEL_URL_HIDE_ALL);
+		camel_url_free (uri);
 
 		for (i=0;status == 0 && i<m->recents->len;i++) {
 			gchar *uid = m->recents->pdata[i];
 			gint pc = 100 * i / m->recents->len;
 
-			camel_operation_progress(NULL, pc);
+			camel_operation_progress (NULL, pc);
 
-			info = camel_folder_get_message_info(m->folder, uid);
+			info = camel_folder_get_message_info (m->folder, uid);
 			if (info == NULL) {
-				g_warning("uid %s vanished from folder: %s", uid, source_url);
+				g_warning ("uid %s vanished from folder: %s", uid, source_url);
 				continue;
 			}
 
-			status = camel_filter_driver_filter_message(m->driver, NULL, info, uid, m->folder, source_url, source_url, &m->ex);
+			status = camel_filter_driver_filter_message (m->driver, NULL, info, uid, m->folder, source_url, source_url, &m->ex);
 
-			camel_folder_free_message_info(m->folder, info);
+			camel_folder_free_message_info (m->folder, info);
 		}
 
-		camel_filter_driver_flush(m->driver, &ex);
-		if (!camel_exception_is_set(&m->ex))
-			camel_exception_xfer(&m->ex, &ex);
+		camel_filter_driver_flush (m->driver, &ex);
+		if (!camel_exception_is_set (&m->ex))
+			camel_exception_xfer (&m->ex, &ex);
 
-		g_free(source_url);
+		g_free (source_url);
 
-		camel_operation_end(NULL);
+		camel_operation_end (NULL);
 	}
 }
 
 static void
-filter_free(CamelSession *session, CamelSessionThreadMsg *msg)
+filter_free (CamelSession *session, CamelSessionThreadMsg *msg)
 {
 	struct _folder_filter_msg *m = (struct _folder_filter_msg *)msg;
 
 	if (m->driver)
-		camel_object_unref(m->driver);
+		camel_object_unref (m->driver);
 	if (m->recents)
-		camel_folder_free_deep(m->folder, m->recents);
+		camel_folder_free_deep (m->folder, m->recents);
 	if (m->junk)
-		camel_folder_free_deep(m->folder, m->junk);
+		camel_folder_free_deep (m->folder, m->junk);
 	if (m->notjunk)
-		camel_folder_free_deep(m->folder, m->notjunk);
+		camel_folder_free_deep (m->folder, m->notjunk);
 
 	camel_folder_summary_save_to_db (m->folder->summary, &m->ex);
-	camel_folder_thaw(m->folder);
-	camel_object_unref(m->folder);
+	camel_folder_thaw (m->folder);
+	camel_object_unref (m->folder);
 }
 
 static CamelSessionThreadOps filter_ops = {
@@ -2069,26 +2066,26 @@ folder_changed (CamelObject *obj, gpointer event_data)
 	GPtrArray *recents = NULL;
 	gint i;
 
-	d(printf ("folder_changed(%p:'%s', %p), frozen=%d\n", obj, folder->full_name, event_data, folder->priv->frozen));
-	d(printf(" added %d removed %d changed %d recent %d filter %d\n",
+	d (printf ("folder_changed (%p:'%s', %p), frozen=%d\n", obj, folder->full_name, event_data, folder->priv->frozen));
+	d (printf (" added %d removed %d changed %d recent %d filter %d\n",
 		 changed->uid_added->len, changed->uid_removed->len,
 		 changed->uid_changed->len, changed->uid_recent->len,
 		 p->uid_filter->len));
 
 	if (changed == NULL) {
-		w(g_warning ("Class %s is passing NULL to folder_changed event",
+		w (g_warning ("Class %s is passing NULL to folder_changed event",
 			     camel_type_to_name (CAMEL_OBJECT_GET_TYPE (folder))));
 		return TRUE;
 	}
 
-	CAMEL_FOLDER_LOCK(folder, change_lock);
+	CAMEL_FOLDER_LOCK (folder, change_lock);
 	if (folder->priv->frozen) {
-		camel_folder_change_info_cat(folder->priv->changed_frozen, changed);
-		CAMEL_FOLDER_UNLOCK(folder, change_lock);
+		camel_folder_change_info_cat (folder->priv->changed_frozen, changed);
+		CAMEL_FOLDER_UNLOCK (folder, change_lock);
 
 		return FALSE;
 	}
-	CAMEL_FOLDER_UNLOCK(folder, change_lock);
+	CAMEL_FOLDER_UNLOCK (folder, change_lock);
 
 	if (session->junk_plugin && changed->uid_changed->len) {
 		guint32 flags;
@@ -2098,11 +2095,11 @@ folder_changed (CamelObject *obj, gpointer event_data)
 			if (flags & CAMEL_MESSAGE_JUNK_LEARN) {
 				if (flags & CAMEL_MESSAGE_JUNK) {
 					if (!junk)
-						junk = g_ptr_array_new();
+						junk = g_ptr_array_new ();
 					g_ptr_array_add (junk, g_strdup (changed->uid_changed->pdata [i]));
 				} else {
 					if (!notjunk)
-						notjunk = g_ptr_array_new();
+						notjunk = g_ptr_array_new ();
 					g_ptr_array_add (notjunk, g_strdup (changed->uid_changed->pdata [i]));
 				}
 				/* reset junk learn flag so that we don't process it again*/
@@ -2113,12 +2110,12 @@ folder_changed (CamelObject *obj, gpointer event_data)
 
 	if ((folder->folder_flags & (CAMEL_FOLDER_FILTER_RECENT|CAMEL_FOLDER_FILTER_JUNK))
 	    && p->uid_filter->len > 0)
-		driver = camel_session_get_filter_driver(session,
+		driver = camel_session_get_filter_driver (session,
 							 (folder->folder_flags & CAMEL_FOLDER_FILTER_RECENT)
 							 ? "incoming":"junktest", NULL);
 
 	if (driver) {
-		recents = g_ptr_array_new();
+		recents = g_ptr_array_new ();
 		for (i = 0; i < p->uid_filter->len; i++)
 			g_ptr_array_add (recents, g_strdup (p->uid_filter->pdata[i]));
 
@@ -2128,24 +2125,23 @@ folder_changed (CamelObject *obj, gpointer event_data)
 	if (driver || junk || notjunk) {
 		struct _folder_filter_msg *msg;
 
-		d(printf("* launching filter thread %d new mail, %d junk and %d not junk\n",
+		d (printf ("* launching filter thread %d new mail, %d junk and %d not junk\n",
 			 recents?recents->len:0, junk?junk->len:0, notjunk?notjunk->len:0));
 
-		msg = camel_session_thread_msg_new(session, &filter_ops, sizeof(*msg));
+		msg = camel_session_thread_msg_new (session, &filter_ops, sizeof (*msg));
 		msg->recents = recents;
 		msg->junk = junk;
 		msg->notjunk = notjunk;
-		msg->folder = folder;
-		camel_object_ref(folder);
-		camel_folder_freeze(folder);
+		msg->folder = camel_object_ref (folder);
+		camel_folder_freeze (folder);
 		/* Copy changes back to changed_frozen list to retain
 		 * them while we are filtering */
-		CAMEL_FOLDER_LOCK(folder, change_lock);
-		camel_folder_change_info_cat(folder->priv->changed_frozen, changed);
-		CAMEL_FOLDER_UNLOCK(folder, change_lock);
+		CAMEL_FOLDER_LOCK (folder, change_lock);
+		camel_folder_change_info_cat (folder->priv->changed_frozen, changed);
+		CAMEL_FOLDER_UNLOCK (folder, change_lock);
 		msg->driver = driver;
-		camel_exception_init(&msg->ex);
-		camel_session_thread_queue(session, &msg->msg, 0);
+		camel_exception_init (&msg->ex);
+		camel_session_thread_queue (session, &msg->msg, 0);
 		return FALSE;
 	}
 
@@ -2213,20 +2209,20 @@ camel_folder_free_deep (CamelFolder *folder, GPtrArray *array)
  * Returns: a new #CamelFolderChangeInfo
  **/
 CamelFolderChangeInfo *
-camel_folder_change_info_new(void)
+camel_folder_change_info_new (void)
 {
 	CamelFolderChangeInfo *info;
 
 	info = g_slice_new (CamelFolderChangeInfo);
-	info->uid_added = g_ptr_array_new();
-	info->uid_removed = g_ptr_array_new();
-	info->uid_changed = g_ptr_array_new();
-	info->uid_recent = g_ptr_array_new();
+	info->uid_added = g_ptr_array_new ();
+	info->uid_removed = g_ptr_array_new ();
+	info->uid_changed = g_ptr_array_new ();
+	info->uid_recent = g_ptr_array_new ();
 	info->priv = g_slice_new (struct _CamelFolderChangeInfoPrivate);
-	info->priv->uid_stored = g_hash_table_new(g_str_hash, g_str_equal);
+	info->priv->uid_stored = g_hash_table_new (g_str_hash, g_str_equal);
 	info->priv->uid_source = NULL;
-	info->priv->uid_filter = g_ptr_array_new();
-	info->priv->uid_pool = camel_mempool_new(512, 256, CAMEL_MEMPOOL_ALIGN_BYTE);
+	info->priv->uid_filter = g_ptr_array_new ();
+	info->priv->uid_pool = camel_mempool_new (512, 256, CAMEL_MEMPOOL_ALIGN_BYTE);
 
 	return info;
 }
@@ -2239,19 +2235,19 @@ camel_folder_change_info_new(void)
  * Add a source uid for generating a changeset.
  **/
 void
-camel_folder_change_info_add_source(CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_add_source (CamelFolderChangeInfo *info, const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
 	p = info->priv;
 
 	if (p->uid_source == NULL)
-		p->uid_source = g_hash_table_new(g_str_hash, g_str_equal);
+		p->uid_source = g_hash_table_new (g_str_hash, g_str_equal);
 
-	if (g_hash_table_lookup(p->uid_source, uid) == NULL)
-		g_hash_table_insert(p->uid_source, camel_mempool_strdup(p->uid_pool, uid), GINT_TO_POINTER (1));
+	if (g_hash_table_lookup (p->uid_source, uid) == NULL)
+		g_hash_table_insert (p->uid_source, camel_mempool_strdup (p->uid_pool, uid), GINT_TO_POINTER (1));
 }
 
 /**
@@ -2262,24 +2258,24 @@ camel_folder_change_info_add_source(CamelFolderChangeInfo *info, const gchar *ui
  * Add a list of source uid's for generating a changeset.
  **/
 void
-camel_folder_change_info_add_source_list(CamelFolderChangeInfo *info, const GPtrArray *list)
+camel_folder_change_info_add_source_list (CamelFolderChangeInfo *info, const GPtrArray *list)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	gint i;
 
-	g_assert(info != NULL);
-	g_assert(list != NULL);
+	g_assert (info != NULL);
+	g_assert (list != NULL);
 
 	p = info->priv;
 
 	if (p->uid_source == NULL)
-		p->uid_source = g_hash_table_new(g_str_hash, g_str_equal);
+		p->uid_source = g_hash_table_new (g_str_hash, g_str_equal);
 
 	for (i=0;i<list->len;i++) {
 		gchar *uid = list->pdata[i];
 
-		if (g_hash_table_lookup(p->uid_source, uid) == NULL)
-			g_hash_table_insert(p->uid_source, camel_mempool_strdup(p->uid_pool, uid), GINT_TO_POINTER (1));
+		if (g_hash_table_lookup (p->uid_source, uid) == NULL)
+			g_hash_table_insert (p->uid_source, camel_mempool_strdup (p->uid_pool, uid), GINT_TO_POINTER (1));
 	}
 }
 
@@ -2291,25 +2287,25 @@ camel_folder_change_info_add_source_list(CamelFolderChangeInfo *info, const GPtr
  * Add a uid from the updated list, used to generate a changeset diff.
  **/
 void
-camel_folder_change_info_add_update(CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_add_update (CamelFolderChangeInfo *info, const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	gchar *key;
 	gint value;
 
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
 	p = info->priv;
 
 	if (p->uid_source == NULL) {
-		camel_folder_change_info_add_uid(info, uid);
+		camel_folder_change_info_add_uid (info, uid);
 		return;
 	}
 
-	if (g_hash_table_lookup_extended(p->uid_source, uid, (gpointer) &key, (gpointer) &value)) {
-		g_hash_table_remove(p->uid_source, key);
+	if (g_hash_table_lookup_extended (p->uid_source, uid, (gpointer) &key, (gpointer) &value)) {
+		g_hash_table_remove (p->uid_source, key);
 	} else {
-		camel_folder_change_info_add_uid(info, uid);
+		camel_folder_change_info_add_uid (info, uid);
 	}
 }
 
@@ -2321,37 +2317,37 @@ camel_folder_change_info_add_update(CamelFolderChangeInfo *info, const gchar *ui
  * Add a list of uid's from the updated list.
  **/
 void
-camel_folder_change_info_add_update_list(CamelFolderChangeInfo *info, const GPtrArray *list)
+camel_folder_change_info_add_update_list (CamelFolderChangeInfo *info, const GPtrArray *list)
 {
 	gint i;
 
-	g_assert(info != NULL);
-	g_assert(list != NULL);
+	g_assert (info != NULL);
+	g_assert (list != NULL);
 
 	for (i=0;i<list->len;i++)
-		camel_folder_change_info_add_update(info, list->pdata[i]);
+		camel_folder_change_info_add_update (info, list->pdata[i]);
 }
 
 static void
-change_info_remove(gchar *key, gpointer value, CamelFolderChangeInfo *info)
+change_info_remove (gchar *key, gpointer value, CamelFolderChangeInfo *info)
 {
 	struct _CamelFolderChangeInfoPrivate *p = info->priv;
 	GPtrArray *olduids;
 	gchar *olduid;
 
-	if (g_hash_table_lookup_extended(p->uid_stored, key, (gpointer) &olduid, (gpointer) &olduids)) {
+	if (g_hash_table_lookup_extended (p->uid_stored, key, (gpointer) &olduid, (gpointer) &olduids)) {
 		/* if it was added/changed them removed, then remove it */
 		if (olduids != info->uid_removed) {
-			g_ptr_array_remove_fast(olduids, olduid);
-			g_ptr_array_add(info->uid_removed, olduid);
-			g_hash_table_insert(p->uid_stored, olduid, info->uid_removed);
+			g_ptr_array_remove_fast (olduids, olduid);
+			g_ptr_array_add (info->uid_removed, olduid);
+			g_hash_table_insert (p->uid_stored, olduid, info->uid_removed);
 		}
 		return;
 	}
 
 	/* we dont need to copy this, as they've already been copied into our pool */
-	g_ptr_array_add(info->uid_removed, key);
-	g_hash_table_insert(p->uid_stored, key, info->uid_removed);
+	g_ptr_array_add (info->uid_removed, key);
+	g_hash_table_insert (p->uid_stored, key, info->uid_removed);
 }
 
 /**
@@ -2362,23 +2358,23 @@ change_info_remove(gchar *key, gpointer value, CamelFolderChangeInfo *info)
  * differences into the added and removed lists.
  **/
 void
-camel_folder_change_info_build_diff(CamelFolderChangeInfo *info)
+camel_folder_change_info_build_diff (CamelFolderChangeInfo *info)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
 	p = info->priv;
 
 	if (p->uid_source) {
-		g_hash_table_foreach(p->uid_source, (GHFunc)change_info_remove, info);
-		g_hash_table_destroy(p->uid_source);
+		g_hash_table_foreach (p->uid_source, (GHFunc)change_info_remove, info);
+		g_hash_table_destroy (p->uid_source);
 		p->uid_source = NULL;
 	}
 }
 
 static void
-change_info_recent_uid(CamelFolderChangeInfo *info, const gchar *uid)
+change_info_recent_uid (CamelFolderChangeInfo *info, const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	GPtrArray *olduids;
@@ -2387,14 +2383,14 @@ change_info_recent_uid(CamelFolderChangeInfo *info, const gchar *uid)
 	p = info->priv;
 
 	/* always add to recent, but dont let anyone else know */
-	if (!g_hash_table_lookup_extended(p->uid_stored, uid, (gpointer *)&olduid, (gpointer *)&olduids)) {
-		olduid = camel_mempool_strdup(p->uid_pool, uid);
+	if (!g_hash_table_lookup_extended (p->uid_stored, uid, (gpointer *)&olduid, (gpointer *)&olduids)) {
+		olduid = camel_mempool_strdup (p->uid_pool, uid);
 	}
-	g_ptr_array_add(info->uid_recent, olduid);
+	g_ptr_array_add (info->uid_recent, olduid);
 }
 
 static void
-change_info_filter_uid(CamelFolderChangeInfo *info, const gchar *uid)
+change_info_filter_uid (CamelFolderChangeInfo *info, const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	GPtrArray *olduids;
@@ -2403,19 +2399,19 @@ change_info_filter_uid(CamelFolderChangeInfo *info, const gchar *uid)
 	p = info->priv;
 
 	/* always add to filter, but dont let anyone else know */
-	if (!g_hash_table_lookup_extended(p->uid_stored, uid, (gpointer *)&olduid, (gpointer *)&olduids)) {
-		olduid = camel_mempool_strdup(p->uid_pool, uid);
+	if (!g_hash_table_lookup_extended (p->uid_stored, uid, (gpointer *)&olduid, (gpointer *)&olduids)) {
+		olduid = camel_mempool_strdup (p->uid_pool, uid);
 	}
-	g_ptr_array_add(p->uid_filter, olduid);
+	g_ptr_array_add (p->uid_filter, olduid);
 }
 
 static void
-change_info_cat(CamelFolderChangeInfo *info, GPtrArray *source, void (*add)(CamelFolderChangeInfo *info, const gchar *uid))
+change_info_cat (CamelFolderChangeInfo *info, GPtrArray *source, void (*add)(CamelFolderChangeInfo *info, const gchar *uid))
 {
 	gint i;
 
 	for (i=0;i<source->len;i++)
-		add(info, source->pdata[i]);
+		add (info, source->pdata[i]);
 }
 
 /**
@@ -2427,16 +2423,16 @@ change_info_cat(CamelFolderChangeInfo *info, GPtrArray *source, void (*add)(Came
  * too.
  **/
 void
-camel_folder_change_info_cat(CamelFolderChangeInfo *info, CamelFolderChangeInfo *source)
+camel_folder_change_info_cat (CamelFolderChangeInfo *info, CamelFolderChangeInfo *source)
 {
-	g_assert(info != NULL);
-	g_assert(source != NULL);
+	g_assert (info != NULL);
+	g_assert (source != NULL);
 
-	change_info_cat(info, source->uid_added, camel_folder_change_info_add_uid);
-	change_info_cat(info, source->uid_removed, camel_folder_change_info_remove_uid);
-	change_info_cat(info, source->uid_changed, camel_folder_change_info_change_uid);
-	change_info_cat(info, source->uid_recent, change_info_recent_uid);
-	change_info_cat(info, source->priv->uid_filter, change_info_filter_uid);
+	change_info_cat (info, source->uid_added, camel_folder_change_info_add_uid);
+	change_info_cat (info, source->uid_removed, camel_folder_change_info_remove_uid);
+	change_info_cat (info, source->uid_changed, camel_folder_change_info_change_uid);
+	change_info_cat (info, source->uid_recent, change_info_recent_uid);
+	change_info_cat (info, source->priv->uid_filter, change_info_filter_uid);
 }
 
 /**
@@ -2447,30 +2443,30 @@ camel_folder_change_info_cat(CamelFolderChangeInfo *info, CamelFolderChangeInfo
  * Add a new uid to the changeinfo.
  **/
 void
-camel_folder_change_info_add_uid(CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_add_uid (CamelFolderChangeInfo *info, const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	GPtrArray *olduids;
 	gchar *olduid;
 
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
 	p = info->priv;
 
-	if (g_hash_table_lookup_extended(p->uid_stored, uid, (gpointer) &olduid, (gpointer) &olduids)) {
+	if (g_hash_table_lookup_extended (p->uid_stored, uid, (gpointer) &olduid, (gpointer) &olduids)) {
 		/* if it was removed then added, promote it to a changed */
 		/* if it was changed then added, leave as changed */
 		if (olduids == info->uid_removed) {
-			g_ptr_array_remove_fast(olduids, olduid);
-			g_ptr_array_add(info->uid_changed, olduid);
-			g_hash_table_insert(p->uid_stored, olduid, info->uid_changed);
+			g_ptr_array_remove_fast (olduids, olduid);
+			g_ptr_array_add (info->uid_changed, olduid);
+			g_hash_table_insert (p->uid_stored, olduid, info->uid_changed);
 		}
 		return;
 	}
 
-	olduid = camel_mempool_strdup(p->uid_pool, uid);
-	g_ptr_array_add(info->uid_added, olduid);
-	g_hash_table_insert(p->uid_stored, olduid, info->uid_added);
+	olduid = camel_mempool_strdup (p->uid_pool, uid);
+	g_ptr_array_add (info->uid_added, olduid);
+	g_hash_table_insert (p->uid_stored, olduid, info->uid_added);
 }
 
 /**
@@ -2481,29 +2477,29 @@ camel_folder_change_info_add_uid(CamelFolderChangeInfo *info, const gchar *uid)
  * Add a uid to the removed uid list.
  **/
 void
-camel_folder_change_info_remove_uid(CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_remove_uid (CamelFolderChangeInfo *info, const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	GPtrArray *olduids;
 	gchar *olduid;
 
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
 	p = info->priv;
 
-	if (g_hash_table_lookup_extended(p->uid_stored, uid, (gpointer) &olduid, (gpointer) &olduids)) {
+	if (g_hash_table_lookup_extended (p->uid_stored, uid, (gpointer) &olduid, (gpointer) &olduids)) {
 		/* if it was added/changed them removed, then remove it */
 		if (olduids != info->uid_removed) {
-			g_ptr_array_remove_fast(olduids, olduid);
-			g_ptr_array_add(info->uid_removed, olduid);
-			g_hash_table_insert(p->uid_stored, olduid, info->uid_removed);
+			g_ptr_array_remove_fast (olduids, olduid);
+			g_ptr_array_add (info->uid_removed, olduid);
+			g_hash_table_insert (p->uid_stored, olduid, info->uid_removed);
 		}
 		return;
 	}
 
-	olduid = camel_mempool_strdup(p->uid_pool, uid);
-	g_ptr_array_add(info->uid_removed, olduid);
-	g_hash_table_insert(p->uid_stored, olduid, info->uid_removed);
+	olduid = camel_mempool_strdup (p->uid_pool, uid);
+	g_ptr_array_add (info->uid_removed, olduid);
+	g_hash_table_insert (p->uid_stored, olduid, info->uid_removed);
 }
 
 /**
@@ -2514,24 +2510,24 @@ camel_folder_change_info_remove_uid(CamelFolderChangeInfo *info, const gchar *ui
  * Add a uid to the changed uid list.
  **/
 void
-camel_folder_change_info_change_uid(CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_change_uid (CamelFolderChangeInfo *info, const gchar *uid)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 	GPtrArray *olduids;
 	gchar *olduid;
 
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
 	p = info->priv;
 
-	if (g_hash_table_lookup_extended(p->uid_stored, uid, (gpointer) &olduid, (gpointer) &olduids)) {
+	if (g_hash_table_lookup_extended (p->uid_stored, uid, (gpointer) &olduid, (gpointer) &olduids)) {
 		/* if we have it already, leave it as that */
 		return;
 	}
 
-	olduid = camel_mempool_strdup(p->uid_pool, uid);
-	g_ptr_array_add(info->uid_changed, olduid);
-	g_hash_table_insert(p->uid_stored, olduid, info->uid_changed);
+	olduid = camel_mempool_strdup (p->uid_pool, uid);
+	g_ptr_array_add (info->uid_changed, olduid);
+	g_hash_table_insert (p->uid_stored, olduid, info->uid_changed);
 }
 
 /**
@@ -2544,12 +2540,12 @@ camel_folder_change_info_change_uid(CamelFolderChangeInfo *info, const gchar *ui
  * filtering
  **/
 void
-camel_folder_change_info_recent_uid(CamelFolderChangeInfo *info, const gchar *uid)
+camel_folder_change_info_recent_uid (CamelFolderChangeInfo *info, const gchar *uid)
 {
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
-	change_info_recent_uid(info, uid);
-	change_info_filter_uid(info, uid);
+	change_info_recent_uid (info, uid);
+	change_info_filter_uid (info, uid);
 }
 
 /**
@@ -2562,9 +2558,9 @@ camel_folder_change_info_recent_uid(CamelFolderChangeInfo *info, const gchar *ui
  * otherwise
  **/
 gboolean
-camel_folder_change_info_changed(CamelFolderChangeInfo *info)
+camel_folder_change_info_changed (CamelFolderChangeInfo *info)
 {
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
 	return (info->uid_added->len || info->uid_removed->len || info->uid_changed->len || info->uid_recent->len);
 }
@@ -2577,26 +2573,26 @@ camel_folder_change_info_changed(CamelFolderChangeInfo *info)
  * processed.
  **/
 void
-camel_folder_change_info_clear(CamelFolderChangeInfo *info)
+camel_folder_change_info_clear (CamelFolderChangeInfo *info)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
 	p = info->priv;
 
-	g_ptr_array_set_size(info->uid_added, 0);
-	g_ptr_array_set_size(info->uid_removed, 0);
-	g_ptr_array_set_size(info->uid_changed, 0);
-	g_ptr_array_set_size(info->uid_recent, 0);
+	g_ptr_array_set_size (info->uid_added, 0);
+	g_ptr_array_set_size (info->uid_removed, 0);
+	g_ptr_array_set_size (info->uid_changed, 0);
+	g_ptr_array_set_size (info->uid_recent, 0);
 	if (p->uid_source) {
-		g_hash_table_destroy(p->uid_source);
+		g_hash_table_destroy (p->uid_source);
 		p->uid_source = NULL;
 	}
-	g_hash_table_destroy(p->uid_stored);
-	p->uid_stored = g_hash_table_new(g_str_hash, g_str_equal);
-	g_ptr_array_set_size(p->uid_filter, 0);
-	camel_mempool_flush(p->uid_pool, TRUE);
+	g_hash_table_destroy (p->uid_stored);
+	p->uid_stored = g_hash_table_new (g_str_hash, g_str_equal);
+	g_ptr_array_set_size (p->uid_filter, 0);
+	camel_mempool_flush (p->uid_pool, TRUE);
 }
 
 /**
@@ -2606,25 +2602,25 @@ camel_folder_change_info_clear(CamelFolderChangeInfo *info)
  * Free memory associated with the folder change info lists.
  **/
 void
-camel_folder_change_info_free(CamelFolderChangeInfo *info)
+camel_folder_change_info_free (CamelFolderChangeInfo *info)
 {
 	struct _CamelFolderChangeInfoPrivate *p;
 
-	g_assert(info != NULL);
+	g_assert (info != NULL);
 
 	p = info->priv;
 
 	if (p->uid_source)
-		g_hash_table_destroy(p->uid_source);
+		g_hash_table_destroy (p->uid_source);
 
-	g_hash_table_destroy(p->uid_stored);
-	g_ptr_array_free(p->uid_filter, TRUE);
-	camel_mempool_destroy(p->uid_pool);
+	g_hash_table_destroy (p->uid_stored);
+	g_ptr_array_free (p->uid_filter, TRUE);
+	camel_mempool_destroy (p->uid_pool);
 	g_slice_free (struct _CamelFolderChangeInfoPrivate, p);
 
-	g_ptr_array_free(info->uid_added, TRUE);
-	g_ptr_array_free(info->uid_removed, TRUE);
-	g_ptr_array_free(info->uid_changed, TRUE);
-	g_ptr_array_free(info->uid_recent, TRUE);
+	g_ptr_array_free (info->uid_added, TRUE);
+	g_ptr_array_free (info->uid_removed, TRUE);
+	g_ptr_array_free (info->uid_changed, TRUE);
+	g_ptr_array_free (info->uid_recent, TRUE);
 	g_slice_free (CamelFolderChangeInfo, info);
 }
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index c5674b8..a637ac5 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -35,6 +35,8 @@
 #define CAMEL_FOLDER(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_FOLDER_TYPE, CamelFolder))
 #define CAMEL_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_FOLDER_TYPE, CamelFolderClass))
 #define CAMEL_IS_FOLDER(o)    (CAMEL_CHECK_TYPE((o), CAMEL_FOLDER_TYPE))
+#define CAMEL_FOLDER_GET_CLASS(obj) \
+	((CamelFolderClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index d4d4cec..07edc01 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -217,8 +217,7 @@ gpg_ctx_new (CamelCipherContext *context)
 
 	gpg = g_new (struct _GpgCtx, 1);
 	gpg->mode = GPG_CTX_MODE_SIGN;
-	gpg->session = session;
-	camel_object_ref (session);
+	gpg->session = camel_object_ref (session);
 	gpg->userid_hint = g_hash_table_new (g_str_hash, g_str_equal);
 	gpg->complete = FALSE;
 	gpg->seen_eof1 = TRUE;
@@ -1428,7 +1427,7 @@ gpg_sign (CamelCipherContext *context,
 	camel_content_type_unref(ct);
 
 	camel_medium_set_content ((CamelMedium *)sigpart, dw);
-	camel_object_unref(dw);
+	camel_object_unref (dw);
 
 	camel_mime_part_set_description(sigpart, "This is a digitally signed message part");
 
@@ -1443,11 +1442,11 @@ gpg_sign (CamelCipherContext *context,
 	mps->signature = sigpart;
 	mps->contentraw = istream;
 	camel_stream_reset(istream);
-	camel_object_ref(istream);
+	camel_object_ref (istream);
 
 	camel_medium_set_content ((CamelMedium *)opart, (CamelDataWrapper *)mps);
 fail:
-	camel_object_unref(ostream);
+	camel_object_unref (ostream);
 
 	if (gpg)
 		gpg_ctx_free (gpg);
@@ -1479,7 +1478,7 @@ swrite (CamelMimePart *sigpart)
 			ret = camel_stream_close (ostream);
 	}
 
-	camel_object_unref(ostream);
+	camel_object_unref (ostream);
 
 	if (ret == -1) {
 		g_unlink (template);
@@ -1600,7 +1599,7 @@ gpg_verify (CamelCipherContext *context,
 			printf("Writing gpg verify data to '%s'\n", name);
 			camel_stream_write_to_stream(istream, out);
 			camel_stream_reset(istream);
-			camel_object_unref(out);
+			camel_object_unref (out);
 		}
 
 		g_free(name);
@@ -1611,7 +1610,7 @@ gpg_verify (CamelCipherContext *context,
 			if (out) {
 				printf("Writing gpg verify signature to '%s'\n", name);
 				camel_data_wrapper_write_to_stream((CamelDataWrapper *)sigpart, out);
-				camel_object_unref(out);
+				camel_object_unref (out);
 			}
 			g_free(name);
 		}
@@ -1803,7 +1802,7 @@ gpg_encrypt (CamelCipherContext *context,
 	camel_content_type_unref(ct);
 
 	camel_medium_set_content ((CamelMedium *)encpart, dw);
-	camel_object_unref(dw);
+	camel_object_unref (dw);
 
 	camel_mime_part_set_description(encpart, _("This is a digitally encrypted message part"));
 
@@ -1826,8 +1825,7 @@ gpg_encrypt (CamelCipherContext *context,
 	camel_content_type_unref(ct);
 	camel_multipart_set_boundary((CamelMultipart *)mpe, NULL);
 
-	mpe->decrypted = ipart;
-	camel_object_ref (ipart);
+	mpe->decrypted = camel_object_ref (ipart);
 
 	camel_multipart_add_part((CamelMultipart *)mpe, verpart);
 	camel_object_unref (verpart);
diff --git a/camel/camel-http-stream.c b/camel/camel-http-stream.c
index f51dce9..29d1a03 100644
--- a/camel/camel-http-stream.c
+++ b/camel/camel-http-stream.c
@@ -317,7 +317,7 @@ static void
 http_stream_finalize (CamelHttpStream *http)
 {
 	if (http->parser)
-		camel_object_unref(http->parser);
+		camel_object_unref (http->parser);
 
 	if (http->content_type)
 		camel_content_type_unref (http->content_type);
@@ -555,8 +555,7 @@ camel_http_stream_new (CamelHttpMethod method, struct _CamelSession *session, Ca
 	stream = CAMEL_HTTP_STREAM (camel_object_new (camel_http_stream_get_type ()));
 
 	stream->method = method;
-	stream->session = session;
-	camel_object_ref(session);
+	stream->session = camel_object_ref (session);
 
 	str = camel_url_to_string (url, 0);
 	stream->url = camel_url_new (str, NULL);
diff --git a/camel/camel-index-control.c b/camel/camel-index-control.c
index 761841e..269d370 100644
--- a/camel/camel-index-control.c
+++ b/camel/camel-index-control.c
@@ -88,7 +88,7 @@ do_info(gint argc, gchar **argv)
 		idx = (CamelIndex *)camel_text_index_new(argv[i], O_RDONLY);
 		if (idx) {
 			camel_text_index_info((CamelTextIndex *)idx);
-			camel_object_unref((CamelObject *)idx);
+			camel_object_unref (idx);
 		} else {
 			printf(" Failed: %s\n", g_strerror (errno));
 			return 0;
diff --git a/camel/camel-index.c b/camel/camel-index.c
index 7aca330..ee9d83d 100644
--- a/camel/camel-index.c
+++ b/camel/camel-index.c
@@ -35,7 +35,7 @@
 
 #define w(x)
 #define io(x)
-#define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
+#define d(x) /*(printf ("%s (%d): ", __FILE__, __LINE__),(x))*/
 
 #define CAMEL_INDEX_VERSION (0x01)
 
@@ -45,8 +45,6 @@ struct _CamelIndexPrivate {
 
 #define _PRIVATE(o) (((CamelIndex *)(o))->priv)
 
-#define CI_CLASS(o) ((CamelIndexClass *)(((CamelObject *)o)->klass))
-
 /* ********************************************************************** */
 /* CamelIndex */
 /* ********************************************************************** */
@@ -54,13 +52,20 @@ struct _CamelIndexPrivate {
 static CamelObjectClass *camel_index_parent;
 
 static void
-camel_index_class_init(CamelIndexClass *klass)
+index_finalize (CamelIndex *index)
+{
+	g_free (index->path);
+	g_free (index->priv);
+}
+
+static void
+camel_index_class_init (CamelIndexClass *klass)
 {
 	camel_index_parent = CAMEL_OBJECT_CLASS(camel_type_get_global_classfuncs(camel_object_get_type()));
 }
 
 static void
-camel_index_init(CamelIndex *idx)
+camel_index_init (CamelIndex *idx)
 {
 	struct _CamelIndexPrivate *p;
 
@@ -69,13 +74,6 @@ camel_index_init(CamelIndex *idx)
 	idx->version = CAMEL_INDEX_VERSION;
 }
 
-static void
-camel_index_finalize(CamelIndex *idx)
-{
-	g_free(idx->path);
-	g_free(idx->priv);
-}
-
 CamelType
 camel_index_get_type(void)
 {
@@ -88,7 +86,7 @@ camel_index_get_type(void)
 					   (CamelObjectClassInitFunc) camel_index_class_init,
 					   NULL,
 					   (CamelObjectInitFunc) camel_index_init,
-					   (CamelObjectFinalizeFunc) camel_index_finalize);
+					   (CamelObjectFinalizeFunc) index_finalize);
 	}
 
 	return type;
@@ -97,28 +95,34 @@ camel_index_get_type(void)
 CamelIndex *
 camel_index_new(const gchar *path, gint flags)
 {
-	CamelIndex *idx = (CamelIndex *)camel_object_new(camel_index_get_type());
+	CamelIndex *idx;
 
-	camel_index_construct(idx, path, flags);
+	idx = (CamelIndex *)camel_object_new(camel_index_get_type());
+	camel_index_construct (idx, path, flags);
 
 	return idx;
 }
 
 void
-camel_index_construct(CamelIndex *idx, const gchar *path, gint flags)
+camel_index_construct (CamelIndex *idx, const gchar *path, gint flags)
 {
-	g_free(idx->path);
-	idx->path = g_strdup_printf("%s.index", path);
+	g_free (idx->path);
+	idx->path = g_strdup_printf ("%s.index", path);
 	idx->flags = flags;
 }
 
 gint
-camel_index_rename(CamelIndex *idx, const gchar *path)
+camel_index_rename (CamelIndex *idx, const gchar *path)
 {
+	CamelIndexClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->rename != NULL, -1);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		return CI_CLASS(idx)->rename(idx, path);
+		return class->rename (idx, path);
 	else {
 		errno = ENOENT;
 		return -1;
@@ -126,7 +130,7 @@ camel_index_rename(CamelIndex *idx, const gchar *path)
 }
 
 void
-camel_index_set_normalize(CamelIndex *idx, CamelIndexNorm func, gpointer data)
+camel_index_set_normalize (CamelIndex *idx, CamelIndexNorm func, gpointer data)
 {
 	g_return_if_fail (CAMEL_IS_INDEX (idx));
 
@@ -135,12 +139,17 @@ camel_index_set_normalize(CamelIndex *idx, CamelIndexNorm func, gpointer data)
 }
 
 gint
-camel_index_sync(CamelIndex *idx)
+camel_index_sync (CamelIndex *idx)
 {
+	CamelIndexClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->sync != NULL, -1);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		return CI_CLASS(idx)->sync(idx);
+		return class->sync (idx);
 	else {
 		errno = ENOENT;
 		return -1;
@@ -148,12 +157,17 @@ camel_index_sync(CamelIndex *idx)
 }
 
 gint
-camel_index_compress(CamelIndex *idx)
+camel_index_compress (CamelIndex *idx)
 {
+	CamelIndexClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->compress != NULL, -1);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		return CI_CLASS(idx)->compress(idx);
+		return class->compress (idx);
 	else {
 		errno = ENOENT;
 		return -1;
@@ -161,14 +175,18 @@ camel_index_compress(CamelIndex *idx)
 }
 
 gint
-camel_index_delete(CamelIndex *idx)
+camel_index_delete (CamelIndex *idx)
 {
+	CamelIndexClass *class;
 	gint ret;
 
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->delete != NULL, -1);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0) {
-		ret = CI_CLASS(idx)->delete(idx);
+		ret = class->delete (idx);
 		idx->state |= CAMEL_INDEX_DELETED;
 	} else {
 		errno = ENOENT;
@@ -179,34 +197,49 @@ camel_index_delete(CamelIndex *idx)
 }
 
 gint
-camel_index_has_name(CamelIndex *idx, const gchar *name)
+camel_index_has_name (CamelIndex *idx, const gchar *name)
 {
+	CamelIndexClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), FALSE);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->has_name != NULL, FALSE);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		return CI_CLASS(idx)->has_name(idx, name);
+		return class->has_name (idx, name);
 	else
 		return FALSE;
 }
 
 CamelIndexName *
-camel_index_add_name(CamelIndex *idx, const gchar *name)
+camel_index_add_name (CamelIndex *idx, const gchar *name)
 {
+	CamelIndexClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->add_name != NULL, NULL);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		return CI_CLASS(idx)->add_name(idx, name);
+		return class->add_name (idx, name);
 	else
 		return NULL;
 }
 
 gint
-camel_index_write_name(CamelIndex *idx, CamelIndexName *idn)
+camel_index_write_name (CamelIndex *idx, CamelIndexName *idn)
 {
+	CamelIndexClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), -1);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->write_name != NULL, -1);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		return CI_CLASS(idx)->write_name(idx, idn);
+		return class->write_name (idx, idn);
 	else {
 		errno = ENOENT;
 		return -1;
@@ -214,65 +247,89 @@ camel_index_write_name(CamelIndex *idx, CamelIndexName *idn)
 }
 
 CamelIndexCursor *
-camel_index_find_name(CamelIndex *idx, const gchar *name)
+camel_index_find_name (CamelIndex *idx, const gchar *name)
 {
+	CamelIndexClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->find_name != NULL, NULL);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		return CI_CLASS(idx)->find_name(idx, name);
+		return class->find_name (idx, name);
 	else
 		return NULL;
 }
 
 void
-camel_index_delete_name(CamelIndex *idx, const gchar *name)
+camel_index_delete_name (CamelIndex *idx, const gchar *name)
 {
+	CamelIndexClass *class;
+
 	g_return_if_fail (CAMEL_IS_INDEX (idx));
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_if_fail (class->delete_name != NULL);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		CI_CLASS(idx)->delete_name(idx, name);
+		class->delete_name (idx, name);
 }
 
 CamelIndexCursor *
-camel_index_find(CamelIndex *idx, const gchar *word)
+camel_index_find (CamelIndex *idx, const gchar *word)
 {
-	gchar *b = (gchar *)word;
+	CamelIndexClass *class;
 	CamelIndexCursor *ret;
+	gchar *b = (gchar *) word;
 
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->find != NULL, NULL);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) != 0)
 		return NULL;
 
 	if (idx->normalize)
-		b = idx->normalize(idx, word, idx->normalize_data);
+		b = idx->normalize (idx, word, idx->normalize_data);
 
-	ret = CI_CLASS(idx)->find(idx, b);
+	ret = class->find (idx, b);
 
 	if (b != word)
-		g_free(b);
+		g_free (b);
 
 	return ret;
 }
 
 CamelIndexCursor *
-camel_index_words(CamelIndex *idx)
+camel_index_words (CamelIndex *idx)
 {
+	CamelIndexClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->words != NULL, NULL);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		return CI_CLASS(idx)->words(idx);
+		return class->words (idx);
 	else
 		return NULL;
 }
 
 CamelIndexCursor *
-camel_index_names(CamelIndex *idx)
+camel_index_names (CamelIndex *idx)
 {
+	CamelIndexClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_INDEX (idx), NULL);
 
+	class = CAMEL_INDEX_GET_CLASS (idx);
+	g_return_val_if_fail (class->names != NULL, NULL);
+
 	if ((idx->state & CAMEL_INDEX_DELETED) == 0)
-		return CI_CLASS(idx)->names(idx);
+		return class->names (idx);
 	else
 		return NULL;
 }
@@ -283,24 +340,22 @@ camel_index_names(CamelIndex *idx)
 
 static CamelObjectClass *camel_index_name_parent;
 
-#define CIN_CLASS(o) ((CamelIndexNameClass *)(((CamelObject *)o)->klass))
-
 static void
-camel_index_name_class_init(CamelIndexNameClass *klass)
+index_name_finalize(CamelIndexName *idn)
 {
-	camel_index_name_parent = CAMEL_OBJECT_CLASS(camel_type_get_global_classfuncs(camel_object_get_type()));
+	if (idn->index)
+		camel_object_unref (idn->index);
 }
 
 static void
-camel_index_name_init(CamelIndexName *idn)
+camel_index_name_class_init(CamelIndexNameClass *klass)
 {
+	camel_index_name_parent = CAMEL_OBJECT_CLASS(camel_type_get_global_classfuncs(camel_object_get_type()));
 }
 
 static void
-camel_index_name_finalize(CamelIndexName *idn)
+camel_index_name_init(CamelIndexName *idn)
 {
-	if (idn->index)
-		camel_object_unref((CamelObject *)idn->index);
 }
 
 CamelType
@@ -315,41 +370,57 @@ camel_index_name_get_type(void)
 					   (CamelObjectClassInitFunc) camel_index_name_class_init,
 					   NULL,
 					   (CamelObjectInitFunc) camel_index_name_init,
-					   (CamelObjectFinalizeFunc) camel_index_name_finalize);
+					   (CamelObjectFinalizeFunc) index_name_finalize);
 	}
 
 	return type;
 }
 
 CamelIndexName *
-camel_index_name_new(CamelIndex *idx, const gchar *name)
+camel_index_name_new (CamelIndex *idx, const gchar *name)
 {
-	CamelIndexName *idn = (CamelIndexName *)camel_object_new(camel_index_name_get_type());
+	CamelIndexName *idn;
 
-	idn->index = idx;
-	camel_object_ref((CamelObject *)idx);
+	idn = (CamelIndexName *)camel_object_new(camel_index_name_get_type());
+	idn->index = camel_object_ref (idx);
 
 	return idn;
 }
 
 void
-camel_index_name_add_word(CamelIndexName *idn, const gchar *word)
+camel_index_name_add_word (CamelIndexName *idn,
+                           const gchar *word)
 {
+	CamelIndexNameClass *class;
 	gchar *b = (gchar *)word;
 
+	g_return_if_fail (CAMEL_IS_INDEX_NAME (idn));
+
+	class = CAMEL_INDEX_NAME_GET_CLASS (idn);
+	g_return_if_fail (class->add_word != NULL);
+
 	if (idn->index->normalize)
-		b = idn->index->normalize(idn->index, word, idn->index->normalize_data);
+		b = idn->index->normalize (idn->index, word, idn->index->normalize_data);
 
-	CIN_CLASS(idn)->add_word(idn, b);
+	class->add_word (idn, b);
 
 	if (b != word)
-		g_free(b);
+		g_free (b);
 }
 
 gsize
-camel_index_name_add_buffer(CamelIndexName *idn, const gchar *buffer, gsize len)
+camel_index_name_add_buffer (CamelIndexName *idn,
+                             const gchar *buffer,
+                             gsize len)
 {
-	return CIN_CLASS(idn)->add_buffer(idn, buffer, len);
+	CamelIndexNameClass *class;
+
+	g_return_val_if_fail (CAMEL_IS_INDEX_NAME (idn), 0);
+
+	class = CAMEL_INDEX_NAME_GET_CLASS (idn);
+	g_return_val_if_fail (class->add_buffer != NULL, 0);
+
+	return class->add_buffer (idn, buffer, len);
 }
 
 /* ********************************************************************** */
@@ -358,24 +429,22 @@ camel_index_name_add_buffer(CamelIndexName *idn, const gchar *buffer, gsize len)
 
 static CamelObjectClass *camel_index_cursor_parent;
 
-#define CIC_CLASS(o) ((CamelIndexCursorClass *)(((CamelObject *)o)->klass))
-
 static void
-camel_index_cursor_class_init(CamelIndexCursorClass *klass)
+index_cursor_finalize (CamelIndexCursor *idc)
 {
-	camel_index_cursor_parent = CAMEL_OBJECT_CLASS(camel_type_get_global_classfuncs(camel_object_get_type()));
+	if (idc->index)
+		camel_object_unref (idc->index);
 }
 
 static void
-camel_index_cursor_init(CamelIndexCursor *idc)
+camel_index_cursor_class_init (CamelIndexCursorClass *klass)
 {
+	camel_index_cursor_parent = CAMEL_OBJECT_CLASS(camel_type_get_global_classfuncs(camel_object_get_type()));
 }
 
 static void
-camel_index_cursor_finalize(CamelIndexCursor *idc)
+camel_index_cursor_init (CamelIndexCursor *idc)
 {
-	if (idc->index)
-		camel_object_unref((CamelObject *)idc->index);
 }
 
 CamelType
@@ -390,32 +459,45 @@ camel_index_cursor_get_type(void)
 					   (CamelObjectClassInitFunc) camel_index_cursor_class_init,
 					   NULL,
 					   (CamelObjectInitFunc) camel_index_cursor_init,
-					   (CamelObjectFinalizeFunc) camel_index_cursor_finalize);
+					   (CamelObjectFinalizeFunc) index_cursor_finalize);
 	}
 
 	return type;
 }
 
 CamelIndexCursor *
-camel_index_cursor_new(CamelIndex *idx, const gchar *name)
+camel_index_cursor_new (CamelIndex *idx, const gchar *name)
 {
-	CamelIndexCursor *idc = (CamelIndexCursor *)camel_object_new(camel_index_cursor_get_type());
+	CamelIndexCursor *idc;
 
-	idc->index = idx;
-	camel_object_ref((CamelObject *)idx);
+	idc = (CamelIndexCursor *)camel_object_new(camel_index_cursor_get_type());
+	idc->index = camel_object_ref (idx);
 
 	return idc;
 }
 
 const gchar *
-camel_index_cursor_next(CamelIndexCursor *idc)
+camel_index_cursor_next (CamelIndexCursor *idc)
 {
-	return CIC_CLASS(idc)->next(idc);
+	CamelIndexCursorClass *class;
+
+	g_return_val_if_fail (CAMEL_IS_INDEX_CURSOR (idc), NULL);
+
+	class = CAMEL_INDEX_CURSOR_GET_CLASS (idc);
+	g_return_val_if_fail (class->next != NULL, NULL);
+
+	return class->next (idc);
 }
 
 void
-camel_index_cursor_reset(CamelIndexCursor *idc)
+camel_index_cursor_reset (CamelIndexCursor *idc)
 {
-	CIC_CLASS(idc)->reset(idc);
-}
+	CamelIndexCursorClass *class;
 
+	g_return_if_fail (CAMEL_IS_INDEX_CURSOR (idc));
+
+	class = CAMEL_INDEX_CURSOR_GET_CLASS (idc);
+	g_return_if_fail (class->reset != NULL);
+
+	class->reset (idc);
+}
diff --git a/camel/camel-index.h b/camel/camel-index.h
index b7c7c58..81ea5b4 100644
--- a/camel/camel-index.h
+++ b/camel/camel-index.h
@@ -31,14 +31,20 @@
 #define CAMEL_INDEX(obj)         CAMEL_CHECK_CAST (obj, camel_index_get_type (), CamelIndex)
 #define CAMEL_INDEX_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_index_get_type (), CamelIndexClass)
 #define CAMEL_IS_INDEX(obj)      CAMEL_CHECK_TYPE (obj, camel_index_get_type ())
+#define CAMEL_INDEX_GET_CLASS(obj) \
+	((CamelIndexClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 #define CAMEL_INDEX_NAME(obj)         CAMEL_CHECK_CAST (obj, camel_index_name_get_type (), CamelIndexName)
 #define CAMEL_INDEX_NAME_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_index_name_get_type (), CamelIndexNameClass)
 #define CAMEL_IS_INDEX_NAME(obj)      CAMEL_CHECK_TYPE (obj, camel_index_name_get_type ())
+#define CAMEL_INDEX_NAME_GET_CLASS(obj) \
+	((CamelIndexNameClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 #define CAMEL_INDEX_CURSOR(obj)         CAMEL_CHECK_CAST (obj, camel_index_cursor_get_type (), CamelIndexCursor)
 #define CAMEL_INDEX_CURSOR_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_index_cursor_get_type (), CamelIndexCursorClass)
 #define CAMEL_IS_INDEX_CURSOR(obj)      CAMEL_CHECK_TYPE (obj, camel_index_cursor_get_type ())
+#define CAMEL_INDEX_CURSOR_GET_CLASS(obj) \
+	((CamelIndexCursorClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index 5102c07..d09279c 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -1071,10 +1071,8 @@ check_content_id (CamelMimeMessage *message, CamelMimePart *part, gpointer data)
 	content_id = camel_mime_part_get_content_id (part);
 
 	found = content_id && !strcmp (content_id, check->content_id) ? TRUE : FALSE;
-	if (found) {
-		check->part = part;
-		camel_object_ref (part);
-	}
+	if (found)
+		check->part = camel_object_ref (part);
 
 	return !found;
 }
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index 3a0c799..8ee3310 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -33,8 +33,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include <glib.h>
-
 #include "camel-mempool.h"
 #include "camel-mime-filter.h"
 #include "camel-mime-parser.h"
@@ -162,9 +160,6 @@ static void folder_push_part(struct _header_scan_state *s, struct _header_scan_s
 static void header_append_mempool(struct _header_scan_state *s, struct _header_scan_stack *h, gchar *header, gint offset);
 #endif
 
-static void camel_mime_parser_class_init (CamelMimeParserClass *klass);
-static void camel_mime_parser_init       (CamelMimeParser *obj);
-
 #if d(!)0
 static gchar *states[] = {
 	"CAMEL_MIME_PARSER_STATE_INITIAL",
@@ -190,28 +185,29 @@ static gchar *states[] = {
 static CamelObjectClass *camel_mime_parser_parent;
 
 static void
-camel_mime_parser_class_init (CamelMimeParserClass *klass)
+mime_parser_finalize (CamelObject *object)
 {
-	camel_mime_parser_parent = camel_type_get_global_classfuncs (camel_object_get_type ());
+	struct _header_scan_state *s = _PRIVATE(object);
+#ifdef PURIFY
+	purify_watch_remove_all();
+#endif
+
+	folder_scan_close(s);
 }
 
 static void
-camel_mime_parser_init (CamelMimeParser *obj)
+camel_mime_parser_class_init (CamelMimeParserClass *class)
 {
-	struct _header_scan_state *s;
-
-	s = folder_scan_init();
-	_PRIVATE(obj) = s;
+	camel_mime_parser_parent = camel_type_get_global_classfuncs (camel_object_get_type ());
 }
 
 static void
-camel_mime_parser_finalize(CamelObject *o)
+camel_mime_parser_init (CamelMimeParser *parser)
 {
-	struct _header_scan_state *s = _PRIVATE(o);
-#ifdef PURIFY
-	purify_watch_remove_all();
-#endif
-	folder_scan_close(s);
+	struct _header_scan_state *s;
+
+	s = folder_scan_init();
+	_PRIVATE(parser) = s;
 }
 
 CamelType
@@ -226,7 +222,7 @@ camel_mime_parser_get_type (void)
 					    (CamelObjectClassInitFunc) camel_mime_parser_class_init,
 					    NULL,
 					    (CamelObjectInitFunc) camel_mime_parser_init,
-					    (CamelObjectFinalizeFunc) camel_mime_parser_finalize);
+					    (CamelObjectFinalizeFunc) mime_parser_finalize);
 	}
 
 	return type;
@@ -242,8 +238,7 @@ camel_mime_parser_get_type (void)
 CamelMimeParser *
 camel_mime_parser_new (void)
 {
-	CamelMimeParser *new = CAMEL_MIME_PARSER ( camel_object_new (camel_mime_parser_get_type ()));
-	return new;
+	return CAMEL_MIME_PARSER (camel_object_new (camel_mime_parser_get_type ()));
 }
 
 /**
@@ -271,12 +266,11 @@ camel_mime_parser_filter_add(CamelMimeParser *m, CamelMimeFilter *mf)
 	struct _header_scan_filter *f, *new;
 
 	new = g_malloc(sizeof(*new));
-	new->filter = mf;
+	new->filter = camel_object_ref (mf);
 	new->id = s->filterid++;
 	if (s->filterid == -1)
 		s->filterid++;
 	new->next = NULL;
-	camel_object_ref((CamelObject *)mf);
 
 	/* yes, this is correct, since 'next' is the first element of the struct */
 	f = (struct _header_scan_filter *)&s->filters;
@@ -306,7 +300,7 @@ camel_mime_parser_filter_remove(CamelMimeParser *m, gint id)
 	while (f && f->next) {
 		old = f->next;
 		if (old->id == id) {
-			camel_object_unref((CamelObject *)old->filter);
+			camel_object_unref (old->filter);
 			f->next = old->next;
 			g_free(old);
 			/* there should only be a single matching id, but
@@ -333,10 +327,9 @@ camel_mime_parser_header(CamelMimeParser *m, const gchar *name, gint *offset)
 {
 	struct _header_scan_state *s = _PRIVATE(m);
 
-	if (s->parts &&
-	    s->parts->headers) {
-		return camel_header_raw_find(&s->parts->headers, name, offset);
-	}
+	if (s->parts && s->parts->headers)
+		return camel_header_raw_find (&s->parts->headers, name, offset);
+
 	return NULL;
 }
 
@@ -479,11 +472,12 @@ camel_mime_parser_init_with_fd(CamelMimeParser *m, gint fd)
  * Returns: -1 on error.
  **/
 gint
-camel_mime_parser_init_with_stream(CamelMimeParser *m, CamelStream *stream)
+camel_mime_parser_init_with_stream (CamelMimeParser *parser,
+                                    CamelStream *stream)
 {
-	struct _header_scan_state *s = _PRIVATE(m);
+	struct _header_scan_state *s = _PRIVATE (parser);
 
-	return folder_scan_init_with_stream(s, stream);
+	return folder_scan_init_with_stream (s, stream);
 }
 
 /**
@@ -970,7 +964,9 @@ folder_seek(struct _header_scan_state *s, off_t offset, gint whence)
 		if (CAMEL_IS_SEEKABLE_STREAM(s->stream)) {
 			/* NOTE: assumes whence seekable stream == whence libc, which is probably
 			   the case (or bloody well should've been) */
-			newoffset = camel_seekable_stream_seek((CamelSeekableStream *)s->stream, offset, whence);
+			newoffset = camel_seekable_stream_seek (
+				CAMEL_SEEKABLE_STREAM (s->stream),
+				offset, whence);
 		} else {
 			newoffset = -1;
 			errno = EINVAL;
@@ -1434,7 +1430,7 @@ folder_scan_close(struct _header_scan_state *s)
 	if (s->fd != -1)
 		close(s->fd);
 	if (s->stream) {
-		camel_object_unref((CamelObject *)s->stream);
+		camel_object_unref (s->stream);
 	}
 	g_free(s);
 }
@@ -1505,7 +1501,7 @@ folder_scan_reset(struct _header_scan_state *s)
 		s->fd = -1;
 	}
 	if (s->stream) {
-		camel_object_unref((CamelObject *)s->stream);
+		camel_object_unref (s->stream);
 		s->stream = NULL;
 	}
 	s->ioerrno = 0;
@@ -1522,11 +1518,11 @@ folder_scan_init_with_fd(struct _header_scan_state *s, gint fd)
 }
 
 static gint
-folder_scan_init_with_stream(struct _header_scan_state *s, CamelStream *stream)
+folder_scan_init_with_stream (struct _header_scan_state *s,
+                              CamelStream *stream)
 {
 	folder_scan_reset(s);
-	s->stream = stream;
-	camel_object_ref((CamelObject *)stream);
+	s->stream = camel_object_ref (stream);
 
 	return 0;
 }
@@ -1622,7 +1618,7 @@ tail_recurse:
 		/* FIXME: should this check for MIME-Version: 1.0 as well? */
 
 		type = CAMEL_MIME_PARSER_STATE_HEADER;
-		if ( (content = camel_header_raw_find(&h->headers, "Content-Type", NULL))
+		if ((content = camel_header_raw_find(&h->headers, "Content-Type", NULL))
 		     && (ct = camel_content_type_decode(content))) {
 			if (!g_ascii_strcasecmp(ct->type, "multipart")) {
 				if (!camel_content_type_is(ct, "multipart", "signed")
@@ -1637,7 +1633,7 @@ tail_recurse:
 					/*camel_content_type_unref(ct);
 					  ct = camel_content_type_decode("text/plain");*/
 /* We can't quite do this, as it will mess up all the offsets ... */
-/*					camel_header_raw_replace(&h->headers, "Content-Type", "text/plain", offset);*/
+/*					camel_header_raw_replace(&h->headers, "Content-Type", "text/plain", offset); */
 					/*g_warning("Multipart with no boundary, treating as text/plain");*/
 				}
 			} else if (!g_ascii_strcasecmp(ct->type, "message")) {
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index 4f02839..de3c10b 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -90,11 +90,7 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse
 	CamelContentType *ct;
 	gchar *encoding;
 
-	/* This replaces the data wrapper repository ... and/or could be
-	 * replaced by it? */
-
-	if (!dw)
-		return;
+	g_return_if_fail (CAMEL_IS_MIME_PART (dw));
 
 	ct = camel_mime_parser_content_type (mp);
 
@@ -152,7 +148,8 @@ camel_mime_part_construct_content_from_parser (CamelMimePart *dw, CamelMimeParse
  * Since: 2.28
  **/
 gboolean
-camel_mime_message_build_preview (CamelMimePart *msg, CamelMessageInfo *info)
+camel_mime_message_build_preview (CamelMimePart *msg,
+                                  CamelMessageInfo *info)
 {
 	CamelDataWrapper *dw;
 	gboolean got_plain = FALSE;
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index 5f2c874..daf548c 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -49,6 +49,18 @@
 
 #define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
 
+struct _CamelMimePartPrivate {
+
+	/* TODO: these should be in a camelcontentinfo */
+	gchar *description;
+	CamelContentDisposition *disposition;
+	gchar *content_id;
+	gchar *content_md5;
+	gchar *content_location;
+	GList *content_languages;
+	CamelTransferEncoding encoding;
+};
+
 typedef enum {
 	HEADER_UNKNOWN,
 	HEADER_DESCRIPTION,
@@ -64,37 +76,62 @@ typedef enum {
 static GHashTable *header_name_table;
 static GHashTable *header_formatted_table;
 
-static CamelMediumClass *parent_class=NULL;
+static gpointer camel_mime_part_parent_class;
 
-/* Returns the class for a CamelMimePart */
-#define CMP_CLASS(so) CAMEL_MIME_PART_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-#define CMD_CLASS(so) CAMEL_MEDIUM_CLASS (CAMEL_OBJECT_GET_CLASS(so))
+static gssize
+write_raw (CamelStream *stream,
+           struct _camel_header_raw *h)
+{
+	gchar *val = h->value;
 
-/* from CamelDataWrapper */
-static gssize         write_to_stream                 (CamelDataWrapper *dw, CamelStream *stream);
-static gint	       construct_from_stream	       (CamelDataWrapper *dw, CamelStream *stream);
+	return camel_stream_printf (
+		stream, "%s%s%s\n", h->name,
+		isspace(val[0]) ? ":" : ": ", val);
+}
 
-/* from CamelMedium */
-static void            add_header                      (CamelMedium *medium, const gchar *name, gconstpointer value);
-static void            set_header                      (CamelMedium *medium, const gchar *name, gconstpointer value);
-static void            remove_header                   (CamelMedium *medium, const gchar *name);
-static const void     *get_header                      (CamelMedium *medium, const gchar *name);
-static GArray         *get_headers                     (CamelMedium *medium);
-static void            free_headers                    (CamelMedium *medium, GArray *headers);
+static gssize
+write_references (CamelStream *stream,
+                  struct _camel_header_raw *h)
+{
+	gssize len, out, total;
+	gchar *value, *ids, *ide;
 
-static void            set_content                     (CamelMedium *medium, CamelDataWrapper *content);
+	/* this is only approximate, based on the next >, this way it retains any content
+	   from the original which may not be properly formatted, etc.  It also doesn't handle
+	   the case where an individual messageid is too long, however thats a bad mail to
+	   start with ... */
 
-/* from camel mime parser */
-static gint             construct_from_parser           (CamelMimePart *mime_part, CamelMimeParser *mp);
+	value = h->value;
+	len = strlen(h->name)+1;
+	total = camel_stream_printf (
+		stream, "%s%s", h->name, isspace(value[0])?":":": ");
+	if (total == -1)
+		return -1;
+	while (*value) {
+		ids = value;
+		ide = strchr(ids+1, '>');
+		if (ide)
+			value = ++ide;
+		else
+			ide = value = strlen(ids)+ids;
 
-/* forward references */
-static void set_disposition (CamelMimePart *mime_part, const gchar *disposition);
+		if (len>0 && len + (ide - ids) >= CAMEL_FOLD_SIZE) {
+			out = camel_stream_printf (stream, "\n\t");
+			if (out == -1)
+				return -1;
+			total += out;
+			len = 0;
+		}
+		out = camel_stream_write (stream, ids, ide-ids);
+		if (out == -1)
+			return -1;
+		len += out;
+		total += out;
+	}
+	camel_stream_write (stream, "\n", 1);
 
-/* format output of headers */
-static gssize write_references(CamelStream *stream, struct _camel_header_raw *h);
-/*static gint write_fold(CamelStream *stream, struct _camel_header_raw *h);*/
-static gssize write_raw(CamelStream *stream, struct _camel_header_raw *h);
+	return total;
+}
 
 /* loads in a hash table the set of header names we */
 /* recognize and associate them with a unique enum  */
@@ -159,85 +196,21 @@ init_header_name_table(void)
 }
 
 static void
-camel_mime_part_class_init (CamelMimePartClass *camel_mime_part_class)
-{
-	CamelMediumClass *camel_medium_class = CAMEL_MEDIUM_CLASS (camel_mime_part_class);
-	CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_mime_part_class);
-
-	parent_class = CAMEL_MEDIUM_CLASS (camel_type_get_global_classfuncs (camel_medium_get_type ()));
-	init_header_name_table();
-
-	camel_mime_part_class->construct_from_parser = construct_from_parser;
-
-	/* virtual method overload */
-	camel_medium_class->add_header                = add_header;
-	camel_medium_class->set_header                = set_header;
-	camel_medium_class->get_header                = get_header;
-	camel_medium_class->remove_header             = remove_header;
-	camel_medium_class->get_headers               = get_headers;
-	camel_medium_class->free_headers              = free_headers;
-	camel_medium_class->set_content               = set_content;
-
-	camel_data_wrapper_class->write_to_stream     = write_to_stream;
-	camel_data_wrapper_class->construct_from_stream= construct_from_stream;
-}
-
-static void
-camel_mime_part_init (gpointer object, gpointer klass)
-{
-	CamelMimePart *mime_part = CAMEL_MIME_PART (object);
-
-	if (((CamelDataWrapper *) mime_part)->mime_type)
-		camel_content_type_unref (((CamelDataWrapper *) mime_part)->mime_type);
-	((CamelDataWrapper *) mime_part)->mime_type = camel_content_type_new ("text", "plain");
-
-	mime_part->description          = NULL;
-	mime_part->disposition          = NULL;
-	mime_part->content_id           = NULL;
-	mime_part->content_MD5          = NULL;
-	mime_part->content_location     = NULL;
-	mime_part->content_languages    = NULL;
-	mime_part->encoding = CAMEL_TRANSFER_ENCODING_DEFAULT;
-}
-
-static void
-camel_mime_part_finalize (CamelObject *object)
+mime_part_set_disposition (CamelMimePart *mime_part,
+                           const gchar *disposition)
 {
-	CamelMimePart *mime_part = CAMEL_MIME_PART (object);
-
-	g_free (mime_part->description);
-	g_free (mime_part->content_id);
-	g_free (mime_part->content_MD5);
-	g_free (mime_part->content_location);
-	camel_string_list_free (mime_part->content_languages);
-	camel_content_disposition_unref(mime_part->disposition);
-
-	camel_header_raw_clear(&mime_part->headers);
-}
-
-CamelType
-camel_mime_part_get_type (void)
-{
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE)	{
-		type = camel_type_register (CAMEL_MEDIUM_TYPE,
-					    "CamelMimePart",
-					    sizeof (CamelMimePart),
-					    sizeof (CamelMimePartClass),
-					    (CamelObjectClassInitFunc) camel_mime_part_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_mime_part_init,
-					    (CamelObjectFinalizeFunc) camel_mime_part_finalize);
-	}
-
-	return type;
+	camel_content_disposition_unref (mime_part->priv->disposition);
+	if (disposition)
+		mime_part->priv->disposition =
+			camel_content_disposition_decode (disposition);
+	else
+		mime_part->priv->disposition = NULL;
 }
 
-/* **** */
-
 static gboolean
-process_header(CamelMedium *medium, const gchar *name, const gchar *value)
+mime_part_process_header (CamelMedium *medium,
+                          const gchar *name,
+                          const gchar *value)
 {
 	CamelMimePart *mime_part = CAMEL_MIME_PART (medium);
 	CamelHeaderType header_type;
@@ -251,33 +224,33 @@ process_header(CamelMedium *medium, const gchar *name, const gchar *value)
 	header_type = (CamelHeaderType) g_hash_table_lookup (header_name_table, name);
 	switch (header_type) {
 	case HEADER_DESCRIPTION: /* raw header->utf8 conversion */
-		g_free (mime_part->description);
+		g_free (mime_part->priv->description);
 		if (((CamelDataWrapper *) mime_part)->mime_type) {
 			charset = camel_content_type_param (((CamelDataWrapper *) mime_part)->mime_type, "charset");
 			charset = camel_iconv_charset_name (charset);
 		} else
 			charset = NULL;
-		mime_part->description = g_strstrip (camel_header_decode_string (value, charset));
+		mime_part->priv->description = g_strstrip (camel_header_decode_string (value, charset));
 		break;
 	case HEADER_DISPOSITION:
-		set_disposition (mime_part, value);
+		mime_part_set_disposition (mime_part, value);
 		break;
 	case HEADER_CONTENT_ID:
-		g_free (mime_part->content_id);
-		mime_part->content_id = camel_header_contentid_decode (value);
+		g_free (mime_part->priv->content_id);
+		mime_part->priv->content_id = camel_header_contentid_decode (value);
 		break;
 	case HEADER_ENCODING:
 		text = camel_header_token_decode (value);
-		mime_part->encoding = camel_transfer_encoding_from_string (text);
+		mime_part->priv->encoding = camel_transfer_encoding_from_string (text);
 		g_free (text);
 		break;
 	case HEADER_CONTENT_MD5:
-		g_free (mime_part->content_MD5);
-		mime_part->content_MD5 = g_strdup (value);
+		g_free (mime_part->priv->content_md5);
+		mime_part->priv->content_md5 = g_strdup (value);
 		break;
 	case HEADER_CONTENT_LOCATION:
-		g_free (mime_part->content_location);
-		mime_part->content_location = camel_header_location_decode (value);
+		g_free (mime_part->priv->content_location);
+		mime_part->priv->content_location = camel_header_location_decode (value);
 		break;
 	case HEADER_CONTENT_TYPE:
 		if (((CamelDataWrapper *) mime_part)->mime_type)
@@ -291,16 +264,27 @@ process_header(CamelMedium *medium, const gchar *name, const gchar *value)
 }
 
 static void
-set_header (CamelMedium *medium, const gchar *name, gconstpointer value)
+mime_part_finalize (CamelMimePart *mime_part)
 {
-	CamelMimePart *part = CAMEL_MIME_PART (medium);
+	CamelMimePartPrivate *priv = mime_part->priv;
+
+	g_free (priv->description);
+	g_free (priv->content_id);
+	g_free (priv->content_md5);
+	g_free (priv->content_location);
+
+	camel_string_list_free (priv->content_languages);
+	camel_content_disposition_unref (priv->disposition);
+
+	camel_header_raw_clear(&mime_part->headers);
 
-	process_header(medium, name, value);
-	camel_header_raw_replace(&part->headers, name, value, -1);
+	g_free (priv);
 }
 
 static void
-add_header (CamelMedium *medium, const gchar *name, gconstpointer value)
+mime_part_add_header (CamelMedium *medium,
+                      const gchar *name,
+                      gconstpointer value)
 {
 	CamelMimePart *part = CAMEL_MIME_PART (medium);
 
@@ -309,31 +293,44 @@ add_header (CamelMedium *medium, const gchar *name, gconstpointer value)
 	/* we simply add the header in a raw fashion                      */
 
 	/* If it was one of the headers we handled, it must be unique, set it instead of add */
-	if (process_header(medium, name, value))
-		camel_header_raw_replace(&part->headers, name, value, -1);
+	if (mime_part_process_header(medium, name, value))
+		camel_header_raw_replace (&part->headers, name, value, -1);
 	else
-		camel_header_raw_append(&part->headers, name, value, -1);
+		camel_header_raw_append (&part->headers, name, value, -1);
+}
+
+static void
+mime_part_set_header (CamelMedium *medium,
+                      const gchar *name,
+                      gconstpointer value)
+{
+	CamelMimePart *part = CAMEL_MIME_PART (medium);
+
+	mime_part_process_header (medium, name, value);
+	camel_header_raw_replace (&part->headers, name, value, -1);
 }
 
 static void
-remove_header (CamelMedium *medium, const gchar *name)
+mime_part_remove_header (CamelMedium *medium,
+                         const gchar *name)
 {
 	CamelMimePart *part = (CamelMimePart *)medium;
 
-	process_header(medium, name, NULL);
-	camel_header_raw_remove(&part->headers, name);
+	mime_part_process_header (medium, name, NULL);
+	camel_header_raw_remove (&part->headers, name);
 }
 
 static gconstpointer
-get_header (CamelMedium *medium, const gchar *name)
+mime_part_get_header (CamelMedium *medium,
+                      const gchar *name)
 {
 	CamelMimePart *part = (CamelMimePart *)medium;
 
-	return camel_header_raw_find(&part->headers, name, NULL);
+	return camel_header_raw_find (&part->headers, name, NULL);
 }
 
 static GArray *
-get_headers (CamelMedium *medium)
+mime_part_get_headers (CamelMedium *medium)
 {
 	CamelMimePart *part = (CamelMimePart *)medium;
 	GArray *headers;
@@ -351,9 +348,325 @@ get_headers (CamelMedium *medium)
 }
 
 static void
-free_headers (CamelMedium *medium, GArray *gheaders)
+mime_part_free_headers (CamelMedium *medium,
+                        GArray *headers)
+{
+	g_array_free (headers, TRUE);
+}
+
+static void
+mime_part_set_content (CamelMedium *medium,
+                       CamelDataWrapper *content)
+{
+	CamelDataWrapper *mime_part = CAMEL_DATA_WRAPPER (medium);
+	CamelMediumClass *medium_class;
+	CamelContentType *content_type;
+
+	/* Chain up to parent's set_content() method. */
+	medium_class = CAMEL_MEDIUM_CLASS (camel_mime_part_parent_class);
+	medium_class->set_content (medium, content);
+
+	content_type = camel_data_wrapper_get_mime_type_field (content);
+	if (mime_part->mime_type != content_type) {
+		gchar *txt;
+
+		txt = camel_content_type_format (content_type);
+		camel_medium_set_header (medium, "Content-Type", txt);
+		g_free (txt);
+	}
+}
+
+static gssize
+mime_part_write_to_stream (CamelDataWrapper *dw,
+                           CamelStream *stream)
+{
+	CamelMimePart *mp = CAMEL_MIME_PART (dw);
+	CamelMedium *medium = CAMEL_MEDIUM (dw);
+	CamelStream *ostream = stream;
+	CamelDataWrapper *content;
+	gssize total = 0;
+	gssize count;
+	gint errnosav;
+
+	d(printf("mime_part::write_to_stream\n"));
+
+	/* FIXME: something needs to be done about this ... */
+	/* TODO: content-languages header? */
+
+	if (mp->headers) {
+		struct _camel_header_raw *h = mp->headers;
+		gchar *val;
+		gssize (*writefn)(CamelStream *stream, struct _camel_header_raw *);
+
+		/* fold/write the headers.   But dont fold headers that are already formatted
+		   (e.g. ones with parameter-lists, that we know about, and have created) */
+		while (h) {
+			val = h->value;
+			if (val == NULL) {
+				g_warning("h->value is NULL here for %s", h->name);
+				count = 0;
+			} else if ((writefn = g_hash_table_lookup(header_formatted_table, h->name)) == NULL) {
+				val = camel_header_fold(val, strlen(h->name));
+				count = camel_stream_printf(stream, "%s%s%s\n", h->name, isspace(val[0]) ? ":" : ": ", val);
+				g_free(val);
+			} else {
+				count = writefn(stream, h);
+			}
+			if (count == -1)
+				return -1;
+			total += count;
+			h = h->next;
+		}
+	}
+
+	count = camel_stream_write (stream, "\n", 1);
+	if (count == -1)
+		return -1;
+	total += count;
+
+	content = camel_medium_get_content (medium);
+	if (content) {
+		CamelMimeFilter *filter = NULL;
+		CamelStream *filter_stream = NULL;
+		CamelMimeFilter *charenc = NULL;
+		const gchar *content_charset = NULL;
+		const gchar *part_charset = NULL;
+		gboolean reencode = FALSE;
+		const gchar *filename;
+
+		if (camel_content_type_is (dw->mime_type, "text", "*")) {
+			content_charset = camel_content_type_param (content->mime_type, "charset");
+			part_charset = camel_content_type_param (dw->mime_type, "charset");
+
+			if (content_charset && part_charset) {
+				content_charset = camel_iconv_charset_name (content_charset);
+				part_charset = camel_iconv_charset_name (part_charset);
+			}
+		}
+
+		if (mp->priv->encoding != content->encoding) {
+			switch (mp->priv->encoding) {
+			case CAMEL_TRANSFER_ENCODING_BASE64:
+				filter = camel_mime_filter_basic_new (CAMEL_MIME_FILTER_BASIC_BASE64_ENC);
+				break;
+			case CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE:
+				filter = camel_mime_filter_basic_new (CAMEL_MIME_FILTER_BASIC_QP_ENC);
+				break;
+			case CAMEL_TRANSFER_ENCODING_UUENCODE:
+				filename = camel_mime_part_get_filename (mp);
+				count = camel_stream_printf (
+					ostream, "begin 644 %s\n",
+					filename ? filename : "untitled");
+				if (count == -1)
+					return -1;
+				total += count;
+				filter = camel_mime_filter_basic_new (CAMEL_MIME_FILTER_BASIC_UU_ENC);
+				break;
+			default:
+				/* content is encoded but the part doesn't want to be... */
+				reencode = TRUE;
+				break;
+			}
+		}
+
+		if (content_charset && part_charset && part_charset != content_charset)
+			charenc = camel_mime_filter_charset_new (content_charset, part_charset);
+
+		if (filter || charenc) {
+			filter_stream = camel_stream_filter_new (stream);
+
+			/* if we have a character encoder, add that always */
+			if (charenc) {
+				camel_stream_filter_add (
+					CAMEL_STREAM_FILTER (filter_stream), charenc);
+				camel_object_unref (charenc);
+			}
+
+			/* we only re-do crlf on encoded blocks */
+			if (filter && camel_content_type_is (dw->mime_type, "text", "*")) {
+				CamelMimeFilter *crlf = camel_mime_filter_crlf_new(CAMEL_MIME_FILTER_CRLF_ENCODE,
+										   CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
+
+				camel_stream_filter_add (
+					CAMEL_STREAM_FILTER (filter_stream), crlf);
+				camel_object_unref (crlf);
+			}
+
+			if (filter) {
+				camel_stream_filter_add (
+					CAMEL_STREAM_FILTER (filter_stream), filter);
+				camel_object_unref (filter);
+			}
+
+			stream = filter_stream;
+
+			reencode = TRUE;
+		}
+
+		if (reencode)
+			count = camel_data_wrapper_decode_to_stream (content, stream);
+		else
+			count = camel_data_wrapper_write_to_stream (content, stream);
+
+		if (filter_stream) {
+			errnosav = errno;
+			camel_stream_flush (stream);
+			camel_object_unref (filter_stream);
+			errno = errnosav;
+		}
+
+		if (count == -1)
+			return -1;
+
+		total += count;
+
+		if (reencode && mp->priv->encoding == CAMEL_TRANSFER_ENCODING_UUENCODE) {
+			count = camel_stream_write (ostream, "end\n", 4);
+			if (count == -1)
+				return -1;
+			total += count;
+		}
+	} else {
+		g_warning("No content for medium, nothing to write");
+	}
+
+	return total;
+}
+
+static gint
+mime_part_construct_from_stream (CamelDataWrapper *dw,
+                                 CamelStream *s)
+{
+	CamelMimeParser *mp;
+	gint ret;
+
+	d(printf("mime_part::construct_from_stream()\n"));
+
+	mp = camel_mime_parser_new();
+	if (camel_mime_parser_init_with_stream (mp, s) == -1) {
+		g_warning ("Cannot create parser for stream");
+		ret = -1;
+	} else {
+		ret = camel_mime_part_construct_from_parser (
+			CAMEL_MIME_PART (dw), mp);
+	}
+	camel_object_unref (mp);
+	return ret;
+}
+
+static gint
+mime_part_construct_from_parser (CamelMimePart *mime_part,
+                                 CamelMimeParser *mp)
+{
+	CamelDataWrapper *dw = (CamelDataWrapper *) mime_part;
+	struct _camel_header_raw *headers;
+	const gchar *content;
+	gchar *buf;
+	gsize len;
+	gint err;
+
+	d(printf("mime_part::construct_from_parser()\n"));
+
+	switch (camel_mime_parser_step(mp, &buf, &len)) {
+	case CAMEL_MIME_PARSER_STATE_MESSAGE:
+		/* set the default type of a message always */
+		if (dw->mime_type)
+			camel_content_type_unref (dw->mime_type);
+		dw->mime_type = camel_content_type_decode ("message/rfc822");
+	case CAMEL_MIME_PARSER_STATE_HEADER:
+	case CAMEL_MIME_PARSER_STATE_MULTIPART:
+		/* we have the headers, build them into 'us' */
+		headers = camel_mime_parser_headers_raw(mp);
+
+		/* if content-type exists, process it first, set for fallback charset in headers */
+		content = camel_header_raw_find(&headers, "content-type", NULL);
+		if (content)
+			mime_part_process_header((CamelMedium *)dw, "content-type", content);
+
+		while (headers) {
+			if (g_ascii_strcasecmp(headers->name, "content-type") == 0
+			    && headers->value != content)
+				camel_medium_add_header((CamelMedium *)dw, "X-Invalid-Content-Type", headers->value);
+			else
+				camel_medium_add_header((CamelMedium *)dw, headers->name, headers->value);
+			headers = headers->next;
+		}
+
+		camel_mime_part_construct_content_from_parser (mime_part, mp);
+		break;
+	default:
+		g_warning("Invalid state encountered???: %u", camel_mime_parser_state(mp));
+	}
+
+	d(printf("mime_part::construct_from_parser() leaving\n"));
+	err = camel_mime_parser_errno(mp);
+	if (err != 0) {
+		errno = err;
+		return -1;
+	}
+
+	return 0;
+}
+
+static void
+camel_mime_part_class_init (CamelMimePartClass *class)
+{
+	CamelMediumClass *medium_class;
+	CamelDataWrapperClass *data_wrapper_class;
+
+	camel_mime_part_parent_class = CAMEL_MEDIUM_CLASS (camel_type_get_global_classfuncs (camel_medium_get_type ()));
+
+	medium_class = CAMEL_MEDIUM_CLASS (class);
+	medium_class->add_header = mime_part_add_header;
+	medium_class->set_header = mime_part_set_header;
+	medium_class->remove_header = mime_part_remove_header;
+	medium_class->get_header = mime_part_get_header;
+	medium_class->get_headers = mime_part_get_headers;
+	medium_class->free_headers = mime_part_free_headers;
+	medium_class->set_content = mime_part_set_content;
+
+	data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class);
+	data_wrapper_class->write_to_stream = mime_part_write_to_stream;
+	data_wrapper_class->construct_from_stream = mime_part_construct_from_stream;
+
+	class->construct_from_parser = mime_part_construct_from_parser;
+
+	init_header_name_table ();
+}
+
+static void
+camel_mime_part_init (CamelMimePart *mime_part)
+{
+	CamelDataWrapper *data_wrapper;
+
+	mime_part->priv = g_new0 (CamelMimePartPrivate, 1);
+	mime_part->priv->encoding = CAMEL_TRANSFER_ENCODING_DEFAULT;
+
+	data_wrapper = CAMEL_DATA_WRAPPER (mime_part);
+
+	if (data_wrapper->mime_type != NULL)
+		camel_content_type_unref (data_wrapper->mime_type);
+
+	data_wrapper->mime_type = camel_content_type_new ("text", "plain");
+}
+
+CamelType
+camel_mime_part_get_type (void)
 {
-	g_array_free (gheaders, TRUE);
+	static CamelType type = CAMEL_INVALID_TYPE;
+
+	if (type == CAMEL_INVALID_TYPE)	{
+		type = camel_type_register (CAMEL_MEDIUM_TYPE,
+					    "CamelMimePart",
+					    sizeof (CamelMimePart),
+					    sizeof (CamelMimePartClass),
+					    (CamelObjectClassInitFunc) camel_mime_part_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_mime_part_init,
+					    (CamelObjectFinalizeFunc) mime_part_finalize);
+	}
+
+	return type;
 }
 
 /* **** Content-Description */
@@ -366,12 +679,19 @@ free_headers (CamelMedium *medium, GArray *gheaders)
  * Set a description on the MIME part.
  **/
 void
-camel_mime_part_set_description (CamelMimePart *mime_part, const gchar *description)
+camel_mime_part_set_description (CamelMimePart *mime_part,
+                                 const gchar *description)
 {
-	gchar *text = camel_header_encode_string ((const guchar *) description);
+	CamelMedium *medium;
+	gchar *text;
+
+	g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
+	g_return_if_fail (description != NULL);
+
+	medium = CAMEL_MEDIUM (mime_part);
 
-	camel_medium_set_header (CAMEL_MEDIUM (mime_part),
-				 "Content-Description", text);
+	text = camel_header_encode_string ((guchar *) description);
+	camel_medium_set_header (medium, "Content-Description", text);
 	g_free (text);
 }
 
@@ -386,21 +706,13 @@ camel_mime_part_set_description (CamelMimePart *mime_part, const gchar *descript
 const gchar *
 camel_mime_part_get_description (CamelMimePart *mime_part)
 {
-	return mime_part->description;
+	g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), NULL);
+
+	return mime_part->priv->description;
 }
 
 /* **** Content-Disposition */
 
-static void
-set_disposition (CamelMimePart *mime_part, const gchar *disposition)
-{
-	camel_content_disposition_unref(mime_part->disposition);
-	if (disposition)
-		mime_part->disposition = camel_content_disposition_decode(disposition);
-	else
-		mime_part->disposition = NULL;
-}
-
 /**
  * camel_mime_part_set_disposition:
  * @mime_part: a #CamelMimePart object
@@ -409,24 +721,28 @@ set_disposition (CamelMimePart *mime_part, const gchar *disposition)
  * Set a disposition on the MIME part.
  **/
 void
-camel_mime_part_set_disposition (CamelMimePart *mime_part, const gchar *disposition)
+camel_mime_part_set_disposition (CamelMimePart *mime_part,
+                                 const gchar *disposition)
 {
+	CamelMedium *medium;
 	gchar *text;
 
+	g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
+
+	medium = CAMEL_MEDIUM (mime_part);
+
 	/* we poke in a new disposition (so we dont lose 'filename', etc) */
-	if (mime_part->disposition == NULL) {
-		set_disposition(mime_part, disposition);
-	}
-	if (mime_part->disposition != NULL) {
-		g_free(mime_part->disposition->disposition);
-		mime_part->disposition->disposition = g_strdup(disposition);
-	}
-	text = camel_content_disposition_format(mime_part->disposition);
+	if (mime_part->priv->disposition == NULL)
+		mime_part_set_disposition (mime_part, disposition);
 
-	camel_medium_set_header (CAMEL_MEDIUM (mime_part),
-				 "Content-Disposition", text);
+	if (mime_part->priv->disposition != NULL) {
+		g_free (mime_part->priv->disposition->disposition);
+		mime_part->priv->disposition->disposition = g_strdup (disposition);
+	}
 
-	g_free(text);
+	text = camel_content_disposition_format (mime_part->priv->disposition);
+	camel_medium_set_header (medium, "Content-Disposition", text);
+	g_free (text);
 }
 
 /**
@@ -440,8 +756,10 @@ camel_mime_part_set_disposition (CamelMimePart *mime_part, const gchar *disposit
 const gchar *
 camel_mime_part_get_disposition (CamelMimePart *mime_part)
 {
-	if (mime_part->disposition)
-		return mime_part->disposition->disposition;
+	g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), NULL);
+
+	if (mime_part->priv->disposition)
+		return mime_part->priv->disposition->disposition;
 	else
 		return NULL;
 }
@@ -462,7 +780,7 @@ camel_mime_part_get_content_disposition (CamelMimePart *mime_part)
 {
 	g_return_val_if_fail (mime_part != NULL, NULL);
 
-	return mime_part->disposition;
+	return mime_part->priv->disposition;
 }
 
 /* **** Content-Disposition: filename="xxx" */
@@ -477,17 +795,21 @@ camel_mime_part_get_content_disposition (CamelMimePart *mime_part)
 void
 camel_mime_part_set_filename (CamelMimePart *mime_part, const gchar *filename)
 {
-	gchar *str;
 	CamelDataWrapper *dw;
+	CamelMedium *medium;
+	gchar *str;
+
+	medium = CAMEL_MEDIUM (mime_part);
 
-	if (mime_part->disposition == NULL)
-		mime_part->disposition = camel_content_disposition_decode("attachment");
+	if (mime_part->priv->disposition == NULL)
+		mime_part->priv->disposition =
+			camel_content_disposition_decode("attachment");
 
-	camel_header_set_param(&mime_part->disposition->params, "filename", filename);
-	str = camel_content_disposition_format(mime_part->disposition);
+	camel_header_set_param (
+		&mime_part->priv->disposition->params, "filename", filename);
+	str = camel_content_disposition_format(mime_part->priv->disposition);
 
-	camel_medium_set_header (CAMEL_MEDIUM (mime_part),
-				 "Content-Disposition", str);
+	camel_medium_set_header (medium, "Content-Disposition", str);
 	g_free(str);
 
 	dw = (CamelDataWrapper *) mime_part;
@@ -495,7 +817,7 @@ camel_mime_part_set_filename (CamelMimePart *mime_part, const gchar *filename)
 		dw->mime_type = camel_content_type_new ("application", "octet-stream");
 	camel_content_type_set_param (dw->mime_type, "name", filename);
 	str = camel_content_type_format (dw->mime_type);
-	camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-Type", str);
+	camel_medium_set_header (medium, "Content-Type", str);
 	g_free (str);
 }
 
@@ -510,8 +832,9 @@ camel_mime_part_set_filename (CamelMimePart *mime_part, const gchar *filename)
 const gchar *
 camel_mime_part_get_filename (CamelMimePart *mime_part)
 {
-	if (mime_part->disposition) {
-		const gchar *name = camel_header_param (mime_part->disposition->params, "filename");
+	if (mime_part->priv->disposition) {
+		const gchar *name = camel_header_param (
+			mime_part->priv->disposition->params, "filename");
 		if (name)
 			return name;
 	}
@@ -529,19 +852,26 @@ camel_mime_part_get_filename (CamelMimePart *mime_part)
  * Set the content-id field on a MIME part.
  **/
 void
-camel_mime_part_set_content_id (CamelMimePart *mime_part, const gchar *contentid)
+camel_mime_part_set_content_id (CamelMimePart *mime_part,
+                                const gchar *contentid)
 {
+	CamelMedium *medium;
 	gchar *cid, *id;
 
+	g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
+
+	medium = CAMEL_MEDIUM (mime_part);
+
 	if (contentid)
 		id = g_strstrip (g_strdup (contentid));
 	else
 		id = camel_header_msgid_generate ();
 
 	cid = g_strdup_printf ("<%s>", id);
-	g_free (id);
-	camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-ID", cid);
+	camel_medium_set_header (medium, "Content-ID", cid);
 	g_free (cid);
+
+	g_free (id);
 }
 
 /**
@@ -555,7 +885,9 @@ camel_mime_part_set_content_id (CamelMimePart *mime_part, const gchar *contentid
 const gchar *
 camel_mime_part_get_content_id (CamelMimePart *mime_part)
 {
-	return mime_part->content_id;
+	g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), NULL);
+
+	return mime_part->priv->content_id;
 }
 
 /* **** Content-MD5: */
@@ -568,9 +900,16 @@ camel_mime_part_get_content_id (CamelMimePart *mime_part)
  * Set the content-md5 field of the MIME part.
  **/
 void
-camel_mime_part_set_content_md5 (CamelMimePart *mime_part, const gchar *md5)
+camel_mime_part_set_content_md5 (CamelMimePart *mime_part,
+                                 const gchar *content_md5)
 {
-	camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-MD5", md5);
+	CamelMedium *medium;
+
+	g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
+
+	medium = CAMEL_MEDIUM (mime_part);
+
+	camel_medium_set_header (medium, "Content-MD5", content_md5);
 }
 
 /**
@@ -584,7 +923,9 @@ camel_mime_part_set_content_md5 (CamelMimePart *mime_part, const gchar *md5)
 const gchar *
 camel_mime_part_get_content_md5 (CamelMimePart *mime_part)
 {
-	return mime_part->content_MD5;
+	g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), NULL);
+
+	return mime_part->priv->content_md5;
 }
 
 /* **** Content-Location: */
@@ -597,10 +938,17 @@ camel_mime_part_get_content_md5 (CamelMimePart *mime_part)
  * Set the content-location field of the MIME part.
  **/
 void
-camel_mime_part_set_content_location (CamelMimePart *mime_part, const gchar *location)
+camel_mime_part_set_content_location (CamelMimePart *mime_part,
+                                      const gchar *location)
 {
+	CamelMedium *medium;
+
+	g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
+
+	medium = CAMEL_MEDIUM (mime_part);
+
 	/* FIXME: this should perform content-location folding */
-	camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-Location", location);
+	camel_medium_set_header (medium, "Content-Location", location);
 }
 
 /**
@@ -614,7 +962,9 @@ camel_mime_part_set_content_location (CamelMimePart *mime_part, const gchar *loc
 const gchar *
 camel_mime_part_get_content_location (CamelMimePart *mime_part)
 {
-	return mime_part->content_location;
+	g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), NULL);
+
+	return mime_part->priv->content_location;
 }
 
 /* **** Content-Transfer-Encoding: */
@@ -628,13 +978,17 @@ camel_mime_part_get_content_location (CamelMimePart *mime_part)
  **/
 void
 camel_mime_part_set_encoding (CamelMimePart *mime_part,
-			      CamelTransferEncoding encoding)
+                              CamelTransferEncoding encoding)
 {
+	CamelMedium *medium;
 	const gchar *text;
 
+	g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
+
+	medium = CAMEL_MEDIUM (mime_part);
+
 	text = camel_transfer_encoding_to_string (encoding);
-	camel_medium_set_header (CAMEL_MEDIUM (mime_part),
-				 "Content-Transfer-Encoding", text);
+	camel_medium_set_header (medium, "Content-Transfer-Encoding", text);
 }
 
 /**
@@ -648,7 +1002,11 @@ camel_mime_part_set_encoding (CamelMimePart *mime_part,
 CamelTransferEncoding
 camel_mime_part_get_encoding (CamelMimePart *mime_part)
 {
-	return mime_part->encoding;
+	g_return_val_if_fail (
+		CAMEL_IS_MIME_PART (mime_part),
+		CAMEL_TRANSFER_ENCODING_DEFAULT);
+
+	return mime_part->priv->encoding;
 }
 
 /* FIXME: do something with this stuff ... */
@@ -661,12 +1019,15 @@ camel_mime_part_get_encoding (CamelMimePart *mime_part)
  * Set the Content-Languages field of a MIME part.
  **/
 void
-camel_mime_part_set_content_languages (CamelMimePart *mime_part, GList *content_languages)
+camel_mime_part_set_content_languages (CamelMimePart *mime_part,
+                                       GList *content_languages)
 {
-	if (mime_part->content_languages)
-		camel_string_list_free (mime_part->content_languages);
+	g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
 
-	mime_part->content_languages = content_languages;
+	if (mime_part->priv->content_languages)
+		camel_string_list_free (mime_part->priv->content_languages);
+
+	mime_part->priv->content_languages = content_languages;
 
 	/* FIXME: translate to a header and set it */
 }
@@ -682,7 +1043,9 @@ camel_mime_part_set_content_languages (CamelMimePart *mime_part, GList *content_
 const GList *
 camel_mime_part_get_content_languages (CamelMimePart *mime_part)
 {
-	return mime_part->content_languages;
+	g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), NULL);
+
+	return mime_part->priv->content_languages;
 }
 
 /* **** */
@@ -697,10 +1060,16 @@ camel_mime_part_get_content_languages (CamelMimePart *mime_part)
  * Set the content-type on a MIME part.
  **/
 void
-camel_mime_part_set_content_type (CamelMimePart *mime_part, const gchar *content_type)
+camel_mime_part_set_content_type (CamelMimePart *mime_part,
+                                  const gchar *content_type)
 {
-	camel_medium_set_header (CAMEL_MEDIUM (mime_part),
-				 "Content-Type", content_type);
+	CamelMedium *medium;
+
+	g_return_if_fail (CAMEL_IS_MIME_PART (mime_part));
+
+	medium = CAMEL_MEDIUM (mime_part);
+
+	camel_medium_set_header (medium, "Content-Type", content_type);
 }
 
 /**
@@ -714,301 +1083,9 @@ camel_mime_part_set_content_type (CamelMimePart *mime_part, const gchar *content
 CamelContentType *
 camel_mime_part_get_content_type (CamelMimePart *mime_part)
 {
-	return ((CamelDataWrapper *) mime_part)->mime_type;
-}
-
-static void
-set_content (CamelMedium *medium, CamelDataWrapper *content)
-{
-	CamelDataWrapper *mime_part = CAMEL_DATA_WRAPPER (medium);
-	CamelContentType *content_type;
-
-	parent_class->set_content (medium, content);
-
-	content_type = camel_data_wrapper_get_mime_type_field (content);
-	if (mime_part->mime_type != content_type) {
-		gchar *txt;
-
-		txt = camel_content_type_format (content_type);
-		camel_medium_set_header (CAMEL_MEDIUM (mime_part), "Content-Type", txt);
-		g_free (txt);
-	}
-}
-
-/**********************************************************************/
-
-static gssize
-write_references(CamelStream *stream, struct _camel_header_raw *h)
-{
-	gssize len, out, total;
-	gchar *v, *ids, *ide;
-
-	/* this is only approximate, based on the next >, this way it retains any content
-	   from the original which may not be properly formatted, etc.  It also doesn't handle
-	   the case where an individual messageid is too long, however thats a bad mail to
-	   start with ... */
-
-	v = h->value;
-	len = strlen(h->name)+1;
-	total = camel_stream_printf(stream, "%s%s", h->name, isspace(v[0])?":":": ");
-	if (total == -1)
-		return -1;
-	while (*v) {
-		ids = v;
-		ide = strchr(ids+1, '>');
-		if (ide)
-			v = ++ide;
-		else
-			ide = v = strlen(ids)+ids;
-
-		if (len>0 && len + (ide - ids) >= CAMEL_FOLD_SIZE) {
-			out = camel_stream_printf(stream, "\n\t");
-			if (out == -1)
-				return -1;
-			total += out;
-			len = 0;
-		}
-		out = camel_stream_write(stream, ids, ide-ids);
-		if (out == -1)
-			return -1;
-		len += out;
-		total += out;
-	}
-	camel_stream_write(stream, "\n", 1);
-
-	return total;
-}
-
-#if 0
-/* not needed - yet - handled by default case */
-static gssize
-write_fold(CamelStream *stream, struct _camel_header_raw *h)
-{
-	gchar *val;
-	gint count;
-
-	val = camel_header_fold(h->value, strlen(h->name));
-	count = camel_stream_printf(stream, "%s%s%s\n", h->name, isspace(val[0]) ? ":" : ": ", val);
-	g_free(val);
-
-	return count;
-}
-#endif
-
-static gssize
-write_raw(CamelStream *stream, struct _camel_header_raw *h)
-{
-	gchar *val = h->value;
-
-	return camel_stream_printf(stream, "%s%s%s\n", h->name, isspace(val[0]) ? ":" : ": ", val);
-}
-
-static gssize
-write_to_stream (CamelDataWrapper *dw, CamelStream *stream)
-{
-	CamelMimePart *mp = CAMEL_MIME_PART (dw);
-	CamelMedium *medium = CAMEL_MEDIUM (dw);
-	CamelStream *ostream = stream;
-	CamelDataWrapper *content;
-	gssize total = 0;
-	gssize count;
-	gint errnosav;
-
-	d(printf("mime_part::write_to_stream\n"));
-
-	/* FIXME: something needs to be done about this ... */
-	/* TODO: content-languages header? */
-
-	if (mp->headers) {
-		struct _camel_header_raw *h = mp->headers;
-		gchar *val;
-		gssize (*writefn)(CamelStream *stream, struct _camel_header_raw *);
-
-		/* fold/write the headers.   But dont fold headers that are already formatted
-		   (e.g. ones with parameter-lists, that we know about, and have created) */
-		while (h) {
-			val = h->value;
-			if (val == NULL) {
-				g_warning("h->value is NULL here for %s", h->name);
-				count = 0;
-			} else if ((writefn = g_hash_table_lookup(header_formatted_table, h->name)) == NULL) {
-				val = camel_header_fold(val, strlen(h->name));
-				count = camel_stream_printf(stream, "%s%s%s\n", h->name, isspace(val[0]) ? ":" : ": ", val);
-				g_free(val);
-			} else {
-				count = writefn(stream, h);
-			}
-			if (count == -1)
-				return -1;
-			total += count;
-			h = h->next;
-		}
-	}
-
-	count = camel_stream_write(stream, "\n", 1);
-	if (count == -1)
-		return -1;
-	total += count;
-
-	content = camel_medium_get_content (medium);
-	if (content) {
-		CamelMimeFilter *filter = NULL;
-		CamelStream *filter_stream = NULL;
-		CamelMimeFilter *charenc = NULL;
-		const gchar *content_charset = NULL;
-		const gchar *part_charset = NULL;
-		gboolean reencode = FALSE;
-		const gchar *filename;
-
-		if (camel_content_type_is (dw->mime_type, "text", "*")) {
-			content_charset = camel_content_type_param (content->mime_type, "charset");
-			part_charset = camel_content_type_param (dw->mime_type, "charset");
-
-			if (content_charset && part_charset) {
-				content_charset = camel_iconv_charset_name (content_charset);
-				part_charset = camel_iconv_charset_name (part_charset);
-			}
-		}
-
-		if (mp->encoding != content->encoding) {
-			switch (mp->encoding) {
-			case CAMEL_TRANSFER_ENCODING_BASE64:
-				filter = camel_mime_filter_basic_new (CAMEL_MIME_FILTER_BASIC_BASE64_ENC);
-				break;
-			case CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE:
-				filter = camel_mime_filter_basic_new (CAMEL_MIME_FILTER_BASIC_QP_ENC);
-				break;
-			case CAMEL_TRANSFER_ENCODING_UUENCODE:
-				filename = camel_mime_part_get_filename (mp);
-				count = camel_stream_printf (ostream, "begin 644 %s\n", filename ? filename : "untitled");
-				if (count == -1)
-					return -1;
-				total += count;
-				filter = camel_mime_filter_basic_new (CAMEL_MIME_FILTER_BASIC_UU_ENC);
-				break;
-			default:
-				/* content is encoded but the part doesn't want to be... */
-				reencode = TRUE;
-				break;
-			}
-		}
-
-		if (content_charset && part_charset && part_charset != content_charset)
-			charenc = camel_mime_filter_charset_new (content_charset, part_charset);
-
-		if (filter || charenc) {
-			filter_stream = camel_stream_filter_new (stream);
-
-			/* if we have a character encoder, add that always */
-			if (charenc) {
-				camel_stream_filter_add (
-					CAMEL_STREAM_FILTER (filter_stream), charenc);
-				camel_object_unref (charenc);
-			}
-
-			/* we only re-do crlf on encoded blocks */
-			if (filter && camel_content_type_is (dw->mime_type, "text", "*")) {
-				CamelMimeFilter *crlf = camel_mime_filter_crlf_new(CAMEL_MIME_FILTER_CRLF_ENCODE,
-										   CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
-
-				camel_stream_filter_add (
-					CAMEL_STREAM_FILTER (filter_stream), crlf);
-				camel_object_unref (crlf);
-			}
-
-			if (filter) {
-				camel_stream_filter_add (
-					CAMEL_STREAM_FILTER (filter_stream), filter);
-				camel_object_unref (filter);
-			}
-
-			stream = (CamelStream *)filter_stream;
-
-			reencode = TRUE;
-		}
-
-		if (reencode)
-			count = camel_data_wrapper_decode_to_stream (content, stream);
-		else
-			count = camel_data_wrapper_write_to_stream (content, stream);
-
-		if (filter_stream) {
-			errnosav = errno;
-			camel_stream_flush (stream);
-			camel_object_unref (filter_stream);
-			errno = errnosav;
-		}
-
-		if (count == -1)
-			return -1;
-
-		total += count;
-
-		if (reencode && mp->encoding == CAMEL_TRANSFER_ENCODING_UUENCODE) {
-			count = camel_stream_write (ostream, "end\n", 4);
-			if (count == -1)
-				return -1;
-			total += count;
-		}
-	} else {
-		g_warning("No content for medium, nothing to write");
-	}
-
-	return total;
-}
-
-/* mime_part */
-static gint
-construct_from_parser (CamelMimePart *mime_part, CamelMimeParser *mp)
-{
-	CamelDataWrapper *dw = (CamelDataWrapper *) mime_part;
-	struct _camel_header_raw *headers;
-	const gchar *content;
-	gchar *buf;
-	gsize len;
-	gint err;
-
-	d(printf("mime_part::construct_from_parser()\n"));
-
-	switch (camel_mime_parser_step(mp, &buf, &len)) {
-	case CAMEL_MIME_PARSER_STATE_MESSAGE:
-		/* set the default type of a message always */
-		if (dw->mime_type)
-			camel_content_type_unref (dw->mime_type);
-		dw->mime_type = camel_content_type_decode ("message/rfc822");
-	case CAMEL_MIME_PARSER_STATE_HEADER:
-	case CAMEL_MIME_PARSER_STATE_MULTIPART:
-		/* we have the headers, build them into 'us' */
-		headers = camel_mime_parser_headers_raw(mp);
-
-		/* if content-type exists, process it first, set for fallback charset in headers */
-		content = camel_header_raw_find(&headers, "content-type", NULL);
-		if (content)
-			process_header((CamelMedium *)dw, "content-type", content);
+	g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), NULL);
 
-		while (headers) {
-			if (g_ascii_strcasecmp(headers->name, "content-type") == 0
-			    && headers->value != content)
-				camel_medium_add_header((CamelMedium *)dw, "X-Invalid-Content-Type", headers->value);
-			else
-				camel_medium_add_header((CamelMedium *)dw, headers->name, headers->value);
-			headers = headers->next;
-		}
-
-		camel_mime_part_construct_content_from_parser (mime_part, mp);
-		break;
-	default:
-		g_warning("Invalid state encountered???: %u", camel_mime_parser_state(mp));
-	}
-
-	d(printf("mime_part::construct_from_parser() leaving\n"));
-	err = camel_mime_parser_errno(mp);
-	if (err != 0) {
-		errno = err;
-		return -1;
-	}
-
-	return 0;
+	return ((CamelDataWrapper *) mime_part)->mime_type;
 }
 
 /**
@@ -1021,33 +1098,20 @@ construct_from_parser (CamelMimePart *mime_part, CamelMimeParser *mp)
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_mime_part_construct_from_parser(CamelMimePart *mime_part, CamelMimeParser *mp)
+camel_mime_part_construct_from_parser (CamelMimePart *mime_part,
+                                       CamelMimeParser *mp)
 {
-	return CMP_CLASS (mime_part)->construct_from_parser (mime_part, mp);
-}
+	CamelMimePartClass *class;
 
-static gint
-construct_from_stream(CamelDataWrapper *dw, CamelStream *s)
-{
-	CamelMimeParser *mp;
-	gint ret;
+	g_return_val_if_fail (CAMEL_IS_MIME_PART (mime_part), -1);
+	g_return_val_if_fail (CAMEL_IS_MIME_PARSER (mp), -1);
 
-	d(printf("mime_part::construct_from_stream()\n"));
+	class = CAMEL_MIME_PART_GET_CLASS (mime_part);
+	g_return_val_if_fail (class->construct_from_parser != NULL, -1);
 
-	mp = camel_mime_parser_new();
-	if (camel_mime_parser_init_with_stream(mp, s) == -1) {
-		g_warning("Cannot create parser for stream");
-		ret = -1;
-	} else {
-		ret = camel_mime_part_construct_from_parser((CamelMimePart *)dw, mp);
-	}
-	camel_object_unref((CamelObject *)mp);
-	return ret;
+	return class->construct_from_parser (mime_part, mp);
 }
 
-/******************************/
-/**  Misc utility functions  **/
-
 /**
  * camel_mime_part_new:
  *
@@ -1091,11 +1155,8 @@ camel_mime_part_set_content (CamelMimePart *mime_part,
 		camel_object_unref (stream);
 		camel_medium_set_content (medium, dw);
 		camel_object_unref (dw);
-	} else {
-		if (medium->content)
-			camel_object_unref (medium->content);
-		medium->content = NULL;
-	}
+	} else
+		camel_medium_set_content (medium, NULL);
 }
 
 /**
diff --git a/camel/camel-mime-part.h b/camel/camel-mime-part.h
index 19f4153..a99ee51 100644
--- a/camel/camel-mime-part.h
+++ b/camel/camel-mime-part.h
@@ -38,27 +38,20 @@
 #define CAMEL_MIME_PART(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_MIME_PART_TYPE, CamelMimePart))
 #define CAMEL_MIME_PART_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MIME_PART_TYPE, CamelMimePartClass))
 #define CAMEL_IS_MIME_PART(o)    (CAMEL_CHECK_TYPE((o), CAMEL_MIME_PART_TYPE))
+#define CAMEL_MIME_PART_GET_CLASS(obj) \
+	((CamelMimePartClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
 typedef struct _CamelMimePart CamelMimePart;
 typedef struct _CamelMimePartClass CamelMimePartClass;
+typedef struct _CamelMimePartPrivate CamelMimePartPrivate;
 
-/* Do not change these values directly, you would regret it one day */
 struct _CamelMimePart {
 	CamelMedium parent;
+	CamelMimePartPrivate *priv;
 
 	struct _camel_header_raw *headers; /* mime headers */
-
-	/* All fields here are -** PRIVATE **- */
-	/* TODO: these should be in a camelcontentinfo */
-	gchar *description;
-	CamelContentDisposition *disposition;
-	gchar *content_id;
-	gchar *content_MD5;
-	gchar *content_location;
-	GList *content_languages;
-	CamelTransferEncoding encoding;
 };
 
 struct _CamelMimePartClass {
@@ -68,7 +61,6 @@ struct _CamelMimePartClass {
 						 CamelMimeParser *parser);
 };
 
-/* Standard Camel function */
 CamelType camel_mime_part_get_type (void);
 
 /* public methods */
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index fe71c83..d5d2093 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -42,8 +42,6 @@
 #define MAXHOSTNAMELEN 1024
 #endif
 
-#include <glib.h>
-
 #include <libedataserver/e-time-utils.h>
 
 #include "camel-charset-map.h"
@@ -4147,17 +4145,17 @@ camel_header_location_decode(const gchar *in)
 
 #ifdef CHECKS
 static void
-check_header(struct _camel_header_raw *h)
+check_header (struct _camel_header_raw *header)
 {
-	guchar *p;
+	guchar *cp;
 
-	p = (guchar *) h->value;
-	while (p && *p) {
-		if (!isascii(*p)) {
-			w(g_warning("Appending header violates rfc: %s: %s", h->name, h->value));
+	cp = (guchar *) header->value;
+	while (cp && *cp) {
+		if (!isascii(*cp)) {
+			w(g_warning("Appending header violates rfc: %s: %s", header->name, header->value));
 			return;
 		}
-		p++;
+		cp++;
 	}
 }
 #endif
diff --git a/camel/camel-multipart-encrypted.c b/camel/camel-multipart-encrypted.c
index 7988bfd..53bd20d 100644
--- a/camel/camel-multipart-encrypted.c
+++ b/camel/camel-multipart-encrypted.c
@@ -27,7 +27,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 
 #include "camel-mime-filter-crlf.h"
@@ -38,80 +37,78 @@
 #include "camel-stream-fs.h"
 #include "camel-stream-mem.h"
 
-static void camel_multipart_encrypted_class_init (CamelMultipartEncryptedClass *klass);
-static void camel_multipart_encrypted_init (gpointer object, gpointer klass);
-static void camel_multipart_encrypted_finalize (CamelObject *object);
+static gpointer camel_multipart_encrypted_parent_class;
 
-static void set_mime_type_field (CamelDataWrapper *data_wrapper, CamelContentType *mime_type);
-
-static CamelMultipartClass *parent_class = NULL;
-
-CamelType
-camel_multipart_encrypted_get_type (void)
+static void
+multipart_encrypted_finalize (CamelMultipartEncrypted *multipart)
 {
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register (camel_multipart_get_type (),
-					    "CamelMultipartEncrypted",
-					    sizeof (CamelMultipartEncrypted),
-					    sizeof (CamelMultipartEncryptedClass),
-					    (CamelObjectClassInitFunc) camel_multipart_encrypted_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_multipart_encrypted_init,
-					    (CamelObjectFinalizeFunc) camel_multipart_encrypted_finalize);
-	}
+	g_free (multipart->protocol);
 
-	return type;
+	if (multipart->decrypted)
+		camel_object_unref (multipart->decrypted);
 }
 
+/* we snoop the mime type to get the protocol */
 static void
-camel_multipart_encrypted_class_init (CamelMultipartEncryptedClass *klass)
+multipart_encrypted_set_mime_type_field (CamelDataWrapper *data_wrapper,
+                                         CamelContentType *mime_type)
 {
-	CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (klass);
+	CamelMultipartEncrypted *multipart;
+	CamelDataWrapperClass *data_wrapper_class;
+
+	multipart = CAMEL_MULTIPART_ENCRYPTED (data_wrapper);
+
+	if (mime_type != NULL) {
+		const gchar *protocol;
 
-	parent_class = (CamelMultipartClass *) camel_multipart_get_type ();
+		protocol = camel_content_type_param (mime_type, "protocol");
+		g_free (multipart->protocol);
+		multipart->protocol = g_strdup (protocol);
+	}
 
-	/* virtual method overload */
-	camel_data_wrapper_class->set_mime_type_field = set_mime_type_field;
+	/* Chain up to parent's set_mime_type_field() method. */
+	data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_multipart_encrypted_parent_class);
+	data_wrapper_class->set_mime_type_field (data_wrapper, mime_type);
 }
 
 static void
-camel_multipart_encrypted_init (gpointer object, gpointer klass)
+camel_multipart_encrypted_class_init (CamelMultipartEncryptedClass *class)
 {
-	CamelMultipartEncrypted *multipart = (CamelMultipartEncrypted *) object;
+	CamelDataWrapperClass *data_wrapper_class;
 
-	camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart), "multipart/encrypted");
+	camel_multipart_encrypted_parent_class = (CamelMultipartClass *) camel_multipart_get_type ();
 
-	multipart->decrypted = NULL;
+	data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class);
+	data_wrapper_class->set_mime_type_field =
+		multipart_encrypted_set_mime_type_field;
 }
 
 static void
-camel_multipart_encrypted_finalize (CamelObject *object)
+camel_multipart_encrypted_init (CamelMultipartEncrypted *multipart)
 {
-	CamelMultipartEncrypted *mpe = (CamelMultipartEncrypted *) object;
-
-	g_free (mpe->protocol);
+	camel_data_wrapper_set_mime_type (
+		CAMEL_DATA_WRAPPER (multipart), "multipart/encrypted");
 
-	if (mpe->decrypted)
-		camel_object_unref (mpe->decrypted);
+	multipart->decrypted = NULL;
 }
 
-/* we snoop the mime type to get the protocol */
-static void
-set_mime_type_field (CamelDataWrapper *data_wrapper, CamelContentType *mime_type)
+CamelType
+camel_multipart_encrypted_get_type (void)
 {
-	CamelMultipartEncrypted *mpe = (CamelMultipartEncrypted *) data_wrapper;
-
-	if (mime_type) {
-		const gchar *protocol;
+	static CamelType type = CAMEL_INVALID_TYPE;
 
-		protocol = camel_content_type_param (mime_type, "protocol");
-		g_free (mpe->protocol);
-		mpe->protocol = g_strdup (protocol);
+	if (type == CAMEL_INVALID_TYPE) {
+		type = camel_type_register (camel_multipart_get_type (),
+					    "CamelMultipartEncrypted",
+					    sizeof (CamelMultipartEncrypted),
+					    sizeof (CamelMultipartEncryptedClass),
+					    (CamelObjectClassInitFunc) camel_multipart_encrypted_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_multipart_encrypted_init,
+					    (CamelObjectFinalizeFunc) multipart_encrypted_finalize);
 	}
 
-	((CamelDataWrapperClass *) parent_class)->set_mime_type_field (data_wrapper, mime_type);
+	return type;
 }
 
 /**
@@ -127,9 +124,5 @@ set_mime_type_field (CamelDataWrapper *data_wrapper, CamelContentType *mime_type
 CamelMultipartEncrypted *
 camel_multipart_encrypted_new (void)
 {
-	CamelMultipartEncrypted *multipart;
-
-	multipart = (CamelMultipartEncrypted *) camel_object_new (CAMEL_MULTIPART_ENCRYPTED_TYPE);
-
-	return multipart;
+	return (CamelMultipartEncrypted *) camel_object_new (CAMEL_MULTIPART_ENCRYPTED_TYPE);
 }
diff --git a/camel/camel-multipart-signed.c b/camel/camel-multipart-signed.c
index cdc871e..53f30c9 100644
--- a/camel/camel-multipart-signed.c
+++ b/camel/camel-multipart-signed.c
@@ -34,7 +34,6 @@
 #include <alloca.h>
 #endif
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 
 #include "camel-exception.h"
@@ -52,136 +51,10 @@
 #define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))
 	       #include <stdio.h>;*/
 
-static void signed_add_part (CamelMultipart *multipart, CamelMimePart *part);
-static void signed_add_part_at (CamelMultipart *multipart, CamelMimePart *part, guint index);
-static void signed_remove_part (CamelMultipart *multipart, CamelMimePart *part);
-static CamelMimePart *signed_remove_part_at (CamelMultipart *multipart, guint index);
-static CamelMimePart *signed_get_part (CamelMultipart *multipart, guint index);
-static guint signed_get_number (CamelMultipart *multipart);
-
-static gssize write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream);
-static void set_mime_type_field (CamelDataWrapper *data_wrapper, CamelContentType *mime_type);
-static gint construct_from_stream (CamelDataWrapper *data_wrapper, CamelStream *stream);
-static gint signed_construct_from_parser (CamelMultipart *multipart, struct _CamelMimeParser *mp);
-
-static CamelMultipartClass *parent_class = NULL;
-
-/* Returns the class for a CamelMultipartSigned */
-#define CMP_CLASS(so) CAMEL_MULTIPART_SIGNED_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-
-/* Returns the class for a CamelDataWrapper */
-#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-
-static void
-camel_multipart_signed_class_init (CamelMultipartSignedClass *camel_multipart_signed_class)
-{
-	CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS(camel_multipart_signed_class);
-	CamelMultipartClass *mpclass = (CamelMultipartClass *)camel_multipart_signed_class;
-
-	parent_class = (CamelMultipartClass *)camel_multipart_get_type();
-
-	/* virtual method overload */
-	camel_data_wrapper_class->construct_from_stream = construct_from_stream;
-	camel_data_wrapper_class->write_to_stream = write_to_stream;
-	camel_data_wrapper_class->decode_to_stream = write_to_stream;
-	camel_data_wrapper_class->set_mime_type_field = set_mime_type_field;
-
-	mpclass->add_part = signed_add_part;
-	mpclass->add_part_at = signed_add_part_at;
-	mpclass->remove_part = signed_remove_part;
-	mpclass->remove_part_at = signed_remove_part_at;
-	mpclass->get_part = signed_get_part;
-	mpclass->get_number = signed_get_number;
-	mpclass->construct_from_parser = signed_construct_from_parser;
-
-/*
-	mpclass->get_boundary = signed_get_boundary;
-	mpclass->set_boundary = signed_set_boundary;
-*/
-}
-
-static void
-camel_multipart_signed_init (gpointer object, gpointer klass)
-{
-	CamelMultipartSigned *multipart = (CamelMultipartSigned *)object;
-
-	camel_data_wrapper_set_mime_type(CAMEL_DATA_WRAPPER(multipart), "multipart/signed");
-	multipart->start1 = -1;
-}
-
-static void
-camel_multipart_signed_finalize (CamelObject *object)
-{
-	CamelMultipartSigned *mps = (CamelMultipartSigned *)object;
-
-	g_free(mps->protocol);
-	g_free(mps->micalg);
-	if (mps->signature)
-		camel_object_unref((CamelObject *)mps->signature);
-	if (mps->content)
-		camel_object_unref((CamelObject *)mps->content);
-	if (mps->contentraw)
-		camel_object_unref((CamelObject *)mps->contentraw);
-}
-
-CamelType
-camel_multipart_signed_get_type (void)
-{
-	static CamelType camel_multipart_signed_type = CAMEL_INVALID_TYPE;
-
-	if (camel_multipart_signed_type == CAMEL_INVALID_TYPE) {
-		camel_multipart_signed_type = camel_type_register (camel_multipart_get_type (), "CamelMultipartSigned",
-								   sizeof (CamelMultipartSigned),
-								   sizeof (CamelMultipartSignedClass),
-								   (CamelObjectClassInitFunc) camel_multipart_signed_class_init,
-								   NULL,
-								   (CamelObjectInitFunc) camel_multipart_signed_init,
-								   (CamelObjectFinalizeFunc) camel_multipart_signed_finalize);
-	}
-
-	return camel_multipart_signed_type;
-}
-
-/**
- * camel_multipart_signed_new:
- *
- * Create a new #CamelMultipartSigned object.
- *
- * A MultipartSigned should be used to store and create parts of
- * type "multipart/signed".  This is because multipart/signed is
- * entirely broken-by-design (tm) and uses completely
- * different semantics to other mutlipart types.  It must be treated
- * as opaque data by any transport.  See rfc 3156 for details.
- *
- * There are 3 ways to create the part:
- * Use construct_from_stream.  If this is used, then you must
- * set the mime_type appropriately to match the data uses, so
- * that the multiple parts my be extracted.
- *
- * Use construct_from_parser.  The parser MUST be in the #CAMEL_MIME_PARSER_STATE_HEADER
- * state, and the current content_type MUST be "multipart/signed" with
- * the appropriate boundary and it SHOULD include the appropriate protocol
- * and hash specifiers.
- *
- * Use sign_part.  A signature part will automatically be created
- * and the whole part may be written using write_to_stream to
- * create a 'transport-safe' version (as safe as can be expected with
- * such a broken specification).
- *
- * Returns: a new #CamelMultipartSigned object
- **/
-CamelMultipartSigned *
-camel_multipart_signed_new (void)
-{
-	CamelMultipartSigned *multipart;
-
-	multipart = (CamelMultipartSigned *)camel_object_new(CAMEL_MULTIPART_SIGNED_TYPE);
-
-	return multipart;
-}
+static gpointer camel_multipart_signed_parent_class;
 
 static gint
-skip_content(CamelMimeParser *cmp)
+multipart_signed_skip_content (CamelMimeParser *cmp)
 {
 	gchar *buf;
 	gsize len;
@@ -196,7 +69,7 @@ skip_content(CamelMimeParser *cmp)
 	case CAMEL_MIME_PARSER_STATE_MESSAGE:
 		/* message body part */
 		(void)camel_mime_parser_step(cmp, &buf, &len);
-		skip_content(cmp);
+		multipart_signed_skip_content (cmp);
 
 		/* clean up followon state if any, see camel-mime-message.c */
 		state = camel_mime_parser_step(cmp, &buf, &len);
@@ -215,7 +88,7 @@ skip_content(CamelMimeParser *cmp)
 	case CAMEL_MIME_PARSER_STATE_MULTIPART:
 		/* embedded multipart */
 		while ((state = camel_mime_parser_step(cmp, &buf, &len)) != CAMEL_MIME_PARSER_STATE_MULTIPART_END)
-			skip_content(cmp);
+			multipart_signed_skip_content (cmp);
 		break;
 	default:
 		g_warning("Invalid state encountered???: %u", camel_mime_parser_state (cmp));
@@ -225,35 +98,29 @@ skip_content(CamelMimeParser *cmp)
 }
 
 static gint
-parse_content(CamelMultipartSigned *mps)
+multipart_signed_parse_content (CamelMultipartSigned *mps)
 {
 	CamelMimeParser *cmp;
 	CamelMultipart *mp = (CamelMultipart *)mps;
-	CamelStreamMem *mem;
+	CamelStream *stream;
 	const gchar *boundary;
 	gchar *buf;
 	gsize len;
 	gint state;
 
-	boundary = camel_multipart_get_boundary(mp);
-	if (boundary == NULL) {
-		g_warning("Trying to get multipart/signed content without setting boundary first");
-		return -1;
-	}
+	boundary = camel_multipart_get_boundary (mp);
+	g_return_val_if_fail (boundary != NULL, -1);
 
-	mem = (CamelStreamMem *)((CamelDataWrapper *)mps)->stream;
-	if (mem == NULL) {
-		g_warning("Trying to parse multipart/signed without constructing first");
-		return -1;
-	}
+	stream = ((CamelDataWrapper *)mps)->stream;
+	g_return_val_if_fail (stream != NULL, -1);
 
 	/* This is all seriously complex.
 	   This is so we can parse all cases properly, without altering the content.
 	   All we are doing is finding part offsets. */
 
-	camel_stream_reset((CamelStream *)mem);
-	cmp = camel_mime_parser_new();
-	camel_mime_parser_init_with_stream(cmp, (CamelStream *)mem);
+	camel_stream_reset (stream);
+	cmp = camel_mime_parser_new ();
+	camel_mime_parser_init_with_stream (cmp, stream);
 	camel_mime_parser_push_state(cmp, CAMEL_MIME_PARSER_STATE_MULTIPART, boundary);
 
 	mps->start1 = -1;
@@ -268,7 +135,7 @@ parse_content(CamelMultipartSigned *mps)
 			GByteArray *buffer;
 
 			buffer = camel_stream_mem_get_byte_array (
-				CAMEL_STREAM_MEM (mem));
+				CAMEL_STREAM_MEM (stream));
 			mps->start2 = camel_mime_parser_tell_start_headers(cmp);
 			mps->end1 = camel_mime_parser_tell_start_boundary(cmp);
 			if (mps->end1 > mps->start1 && buffer->data[mps->end1-1] == '\n')
@@ -280,7 +147,7 @@ parse_content(CamelMultipartSigned *mps)
 			break;
 		}
 
-		if (skip_content(cmp) == -1)
+		if (multipart_signed_skip_content (cmp) == -1)
 			break;
 	}
 
@@ -291,7 +158,7 @@ parse_content(CamelMultipartSigned *mps)
 		camel_multipart_set_postface(mp, camel_mime_parser_postface(cmp));
 	}
 
-	camel_object_unref(cmp);
+	camel_object_unref (cmp);
 
 	if (mps->end2 == -1 || mps->start2 == -1) {
 		return -1;
@@ -300,13 +167,58 @@ parse_content(CamelMultipartSigned *mps)
 	return 0;
 }
 
-/* we snoop the mime type to get boundary and hash info */
 static void
-set_mime_type_field(CamelDataWrapper *data_wrapper, CamelContentType *mime_type)
+multipart_signed_set_stream (CamelMultipartSigned *mps,
+                             CamelStream *stream)
 {
+	CamelDataWrapper *dw = (CamelDataWrapper *)mps;
+
+	if (dw->stream)
+		camel_object_unref (dw->stream);
+	dw->stream = stream;
+
+	mps->start1 = -1;
+	if (mps->content) {
+		camel_object_unref (mps->content);
+		mps->content = NULL;
+	}
+	if (mps->contentraw) {
+		camel_object_unref (mps->contentraw);
+		mps->contentraw = NULL;
+	}
+	if (mps->signature) {
+		camel_object_unref (mps->signature);
+		mps->signature = NULL;
+	}
+}
+
+static void
+multipart_signed_finalize (CamelMultipartSigned *mps)
+{
+	g_free (mps->protocol);
+	g_free (mps->micalg);
+\
+	if (mps->signature)
+		camel_object_unref (mps->signature);
+	if (mps->content)
+		camel_object_unref (mps->content);
+	if (mps->contentraw)
+		camel_object_unref (mps->contentraw);
+}
+
+static void
+multipart_signed_set_mime_type_field (CamelDataWrapper *data_wrapper,
+                                      CamelContentType *mime_type)
+{
+	CamelDataWrapperClass *data_wrapper_class;
 	CamelMultipartSigned *mps = (CamelMultipartSigned *)data_wrapper;
 
-	((CamelDataWrapperClass *)parent_class)->set_mime_type_field(data_wrapper, mime_type);
+	/* we snoop the mime type to get boundary and hash info */
+
+	/* Chain up to parent's set_mime_type_field() method. */
+	data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_multipart_signed_parent_class);
+	data_wrapper_class->set_mime_type_field(data_wrapper, mime_type);
+
 	if (mime_type) {
 		const gchar *micalg, *protocol;
 
@@ -320,33 +232,134 @@ set_mime_type_field(CamelDataWrapper *data_wrapper, CamelContentType *mime_type)
 	}
 }
 
+static gssize
+multipart_signed_write_to_stream (CamelDataWrapper *data_wrapper,
+                                  CamelStream *stream)
+{
+	CamelMultipartSigned *mps = (CamelMultipartSigned *)data_wrapper;
+	CamelMultipart *mp = (CamelMultipart *)mps;
+	const gchar *boundary;
+	gssize total = 0;
+	gssize count;
+
+	/* we have 3 basic cases:
+	   1. constructed, we write out the data wrapper stream we got
+	   2. signed content, we create and write out a new stream
+	   3. invalid
+	*/
+
+	/* 1 */
+	/* FIXME: locking? */
+	if (data_wrapper->stream) {
+		camel_stream_reset (data_wrapper->stream);
+		return camel_stream_write_to_stream (data_wrapper->stream, stream);
+	}
+
+	/* 3 */
+	if (mps->signature == NULL || mps->contentraw == NULL)
+		return -1;
+
+	/* 2 */
+	boundary = camel_multipart_get_boundary(mp);
+	if (mp->preface) {
+		count = camel_stream_write_string (stream, mp->preface);
+		if (count == -1)
+			return -1;
+		total += count;
+	}
+
+	/* first boundary */
+	count = camel_stream_printf (stream, "\n--%s\n", boundary);
+	if (count == -1)
+		return -1;
+	total += count;
+
+	/* output content part */
+	camel_stream_reset (mps->contentraw);
+	count = camel_stream_write_to_stream (mps->contentraw, stream);
+	if (count == -1)
+		return -1;
+	total += count;
+
+	/* boundary */
+	count = camel_stream_printf (stream, "\n--%s\n", boundary);
+	if (count == -1)
+		return -1;
+	total += count;
+
+	/* signature */
+	count = camel_data_wrapper_write_to_stream (
+		CAMEL_DATA_WRAPPER (mps->signature), stream);
+	if (count == -1)
+		return -1;
+	total += count;
+
+	/* write the terminating boudary delimiter */
+	count = camel_stream_printf (stream, "\n--%s--\n", boundary);
+	if (count == -1)
+		return -1;
+	total += count;
+
+	/* and finally the postface */
+	if (mp->postface) {
+		count = camel_stream_write_string (stream, mp->postface);
+		if (count == -1)
+			return -1;
+		total += count;
+	}
+
+	return total;
+}
+
+static gint
+multipart_signed_construct_from_stream (CamelDataWrapper *data_wrapper,
+                                        CamelStream *stream)
+{
+	CamelMultipartSigned *mps = (CamelMultipartSigned *)data_wrapper;
+	CamelStream *mem = camel_stream_mem_new();
+
+	if (camel_stream_write_to_stream (stream, mem) == -1)
+		return -1;
+
+	multipart_signed_set_stream (mps, mem);
+
+	return 0;
+}
+
 static void
-signed_add_part(CamelMultipart *multipart, CamelMimePart *part)
+multipart_signed_add_part (CamelMultipart *multipart,
+                           CamelMimePart *part)
 {
 	g_warning("Cannot add parts to a signed part using add_part");
 }
 
 static void
-signed_add_part_at(CamelMultipart *multipart, CamelMimePart *part, guint index)
+multipart_signed_add_part_at (CamelMultipart *multipart,
+                              CamelMimePart *part,
+                              guint index)
 {
 	g_warning("Cannot add parts to a signed part using add_part_at");
 }
 
 static void
-signed_remove_part(CamelMultipart *multipart, CamelMimePart *part)
+multipart_signed_remove_part (CamelMultipart *multipart,
+                              CamelMimePart *part)
 {
 	g_warning("Cannot remove parts from a signed part using remove_part");
 }
 
 static CamelMimePart *
-signed_remove_part_at (CamelMultipart *multipart, guint index)
+multipart_signed_remove_part_at (CamelMultipart *multipart,
+                                 guint index)
 {
 	g_warning("Cannot remove parts from a signed part using remove_part");
+
 	return NULL;
 }
 
 static CamelMimePart *
-signed_get_part(CamelMultipart *multipart, guint index)
+multipart_signed_get_part (CamelMultipart *multipart,
+                           guint index)
 {
 	CamelMultipartSigned *mps = (CamelMultipartSigned *)multipart;
 	CamelDataWrapper *dw = (CamelDataWrapper *)multipart;
@@ -357,41 +370,41 @@ signed_get_part(CamelMultipart *multipart, guint index)
 		if (mps->content)
 			return mps->content;
 		if (mps->contentraw) {
-			stream = mps->contentraw;
-			camel_object_ref((CamelObject *)stream);
+			stream = camel_object_ref (mps->contentraw);
 		} else if (mps->start1 == -1
-			   && parse_content(mps) == -1
+			   && multipart_signed_parse_content(mps) == -1
 			   && (stream = ((CamelDataWrapper *)mps)->stream) == NULL) {
 			g_warning("Trying to get content on an invalid multipart/signed");
 			return NULL;
 		} else if (dw->stream == NULL) {
 			return NULL;
 		} else if (mps->start1 == -1) {
-			stream = dw->stream;
-			camel_object_ref(stream);
+			stream = camel_object_ref (dw->stream);
 		} else {
 			stream = camel_seekable_substream_new((CamelSeekableStream *)dw->stream, mps->start1, mps->end1);
 		}
-		camel_stream_reset(stream);
+		camel_stream_reset (stream);
 		mps->content = camel_mime_part_new();
-		camel_data_wrapper_construct_from_stream((CamelDataWrapper *)mps->content, stream);
-		camel_object_unref(stream);
+		camel_data_wrapper_construct_from_stream (
+			CAMEL_DATA_WRAPPER (mps->content), stream);
+		camel_object_unref (stream);
 		return mps->content;
 	case CAMEL_MULTIPART_SIGNED_SIGNATURE:
 		if (mps->signature)
 			return mps->signature;
 		if (mps->start1 == -1
-		    && parse_content(mps) == -1) {
+		    && multipart_signed_parse_content(mps) == -1) {
 			g_warning("Trying to get signature on invalid multipart/signed");
 			return NULL;
 		} else if (dw->stream == NULL) {
 			return NULL;
 		}
 		stream = camel_seekable_substream_new((CamelSeekableStream *)dw->stream, mps->start2, mps->end2);
-		camel_stream_reset(stream);
+		camel_stream_reset (stream);
 		mps->signature = camel_mime_part_new();
-		camel_data_wrapper_construct_from_stream((CamelDataWrapper *)mps->signature, stream);
-		camel_object_unref((CamelObject *)stream);
+		camel_data_wrapper_construct_from_stream (
+			CAMEL_DATA_WRAPPER (mps->signature), stream);
+		camel_object_unref (stream);
 		return mps->signature;
 	default:
 		g_warning("trying to get object out of bounds for multipart");
@@ -401,7 +414,7 @@ signed_get_part(CamelMultipart *multipart, guint index)
 }
 
 static guint
-signed_get_number(CamelMultipart *multipart)
+multipart_signed_get_number (CamelMultipart *multipart)
 {
 	CamelDataWrapper *dw = (CamelDataWrapper *)multipart;
 	CamelMultipartSigned *mps = (CamelMultipartSigned *)multipart;
@@ -411,7 +424,7 @@ signed_get_number(CamelMultipart *multipart)
 	if ((mps->content || mps->contentraw) && mps->signature)
 		return 2;
 
-	if (mps->start1 == -1 && parse_content(mps) == -1) {
+	if (mps->start1 == -1 && multipart_signed_parse_content(mps) == -1) {
 		if (dw->stream == NULL)
 			return 0;
 		else
@@ -421,53 +434,16 @@ signed_get_number(CamelMultipart *multipart)
 	}
 }
 
-static void
-set_stream(CamelMultipartSigned *mps, CamelStream *mem)
-{
-	CamelDataWrapper *dw = (CamelDataWrapper *)mps;
-
-	if (dw->stream)
-		camel_object_unref((CamelObject *)dw->stream);
-	dw->stream = (CamelStream *)mem;
-
-	mps->start1 = -1;
-	if (mps->content) {
-		camel_object_unref((CamelObject *)mps->content);
-		mps->content = NULL;
-	}
-	if (mps->contentraw) {
-		camel_object_unref((CamelObject *)mps->contentraw);
-		mps->contentraw = NULL;
-	}
-	if (mps->signature) {
-		camel_object_unref((CamelObject *)mps->signature);
-		mps->signature = NULL;
-	}
-}
-
-static gint
-construct_from_stream(CamelDataWrapper *data_wrapper, CamelStream *stream)
-{
-	CamelMultipartSigned *mps = (CamelMultipartSigned *)data_wrapper;
-	CamelStream *mem = camel_stream_mem_new();
-
-	if (camel_stream_write_to_stream(stream, mem) == -1)
-		return -1;
-
-	set_stream(mps, mem);
-
-	return 0;
-}
-
 static gint
-signed_construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser *mp)
+multipart_signed_construct_from_parser (CamelMultipart *multipart,
+                                        CamelMimeParser *mp)
 {
 	gint err;
 	CamelContentType *content_type;
 	CamelMultipartSigned *mps = (CamelMultipartSigned *)multipart;
 	gchar *buf;
 	gsize len;
-	CamelStream *mem;
+	CamelStream *stream;
 
 	/* we *must not* be in multipart state, otherwise the mime parser will
 	   parse the headers which is a no no @#$ # stupid multipart/signed spec */
@@ -477,11 +453,11 @@ signed_construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser
 	content_type = camel_mime_parser_content_type(mp);
 	camel_multipart_set_boundary(multipart, camel_content_type_param(content_type, "boundary"));
 
-	mem = camel_stream_mem_new();
+	stream = camel_stream_mem_new();
 	while (camel_mime_parser_step(mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_BODY_END)
-		camel_stream_write(mem, buf, len);
+		camel_stream_write(stream, buf, len);
 
-	set_stream(mps, mem);
+	multipart_signed_set_stream (mps, stream);
 
 	err = camel_mime_parser_errno(mp);
 	if (err != 0) {
@@ -491,81 +467,89 @@ signed_construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser
 		return 0;
 }
 
-static gssize
-write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
+static void
+camel_multipart_signed_class_init (CamelMultipartSignedClass *class)
 {
-	CamelMultipartSigned *mps = (CamelMultipartSigned *)data_wrapper;
-	CamelMultipart *mp = (CamelMultipart *)mps;
-	const gchar *boundary;
-	gssize total = 0;
-	gssize count;
+	CamelDataWrapperClass *data_wrapper_class;
+	CamelMultipartClass *multipart_class;
+
+	camel_multipart_signed_parent_class = (CamelMultipartClass *)camel_multipart_get_type();
+
+	data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class);
+	data_wrapper_class->set_mime_type_field = multipart_signed_set_mime_type_field;
+	data_wrapper_class->write_to_stream = multipart_signed_write_to_stream;
+	data_wrapper_class->decode_to_stream = multipart_signed_write_to_stream;
+	data_wrapper_class->construct_from_stream = multipart_signed_construct_from_stream;
+
+	multipart_class = CAMEL_MULTIPART_CLASS (class);
+	multipart_class->add_part = multipart_signed_add_part;
+	multipart_class->add_part_at = multipart_signed_add_part_at;
+	multipart_class->remove_part = multipart_signed_remove_part;
+	multipart_class->remove_part_at = multipart_signed_remove_part_at;
+	multipart_class->get_part = multipart_signed_get_part;
+	multipart_class->get_number = multipart_signed_get_number;
+	multipart_class->construct_from_parser = multipart_signed_construct_from_parser;
+}
 
-	/* we have 3 basic cases:
-	   1. constructed, we write out the data wrapper stream we got
-	   2. signed content, we create and write out a new stream
-	   3. invalid
-	*/
+static void
+camel_multipart_signed_init (CamelMultipartSigned *multipart)
+{
+	camel_data_wrapper_set_mime_type (
+		CAMEL_DATA_WRAPPER (multipart), "multipart/signed");
 
-	/* 1 */
-	/* FIXME: locking? */
-	if (data_wrapper->stream) {
-		camel_stream_reset(data_wrapper->stream);
-		return camel_stream_write_to_stream(data_wrapper->stream, stream);
-	}
+	multipart->start1 = -1;
+}
 
-	/* 3 */
-	if (mps->signature == NULL || mps->contentraw == NULL)
-		return -1;
+CamelType
+camel_multipart_signed_get_type (void)
+{
+	static CamelType camel_multipart_signed_type = CAMEL_INVALID_TYPE;
 
-	/* 2 */
-	boundary = camel_multipart_get_boundary(mp);
-	if (mp->preface) {
-		count = camel_stream_write_string(stream, mp->preface);
-		if (count == -1)
-			return -1;
-		total += count;
+	if (camel_multipart_signed_type == CAMEL_INVALID_TYPE) {
+		camel_multipart_signed_type = camel_type_register (camel_multipart_get_type (), "CamelMultipartSigned",
+								   sizeof (CamelMultipartSigned),
+								   sizeof (CamelMultipartSignedClass),
+								   (CamelObjectClassInitFunc) camel_multipart_signed_class_init,
+								   NULL,
+								   (CamelObjectInitFunc) camel_multipart_signed_init,
+								   (CamelObjectFinalizeFunc) multipart_signed_finalize);
 	}
 
-	/* first boundary */
-	count = camel_stream_printf(stream, "\n--%s\n", boundary);
-	if (count == -1)
-		return -1;
-	total += count;
-
-	/* output content part */
-	camel_stream_reset(mps->contentraw);
-	count = camel_stream_write_to_stream(mps->contentraw, stream);
-	if (count == -1)
-		return -1;
-	total += count;
-
-	/* boundary */
-	count = camel_stream_printf(stream, "\n--%s\n", boundary);
-	if (count == -1)
-		return -1;
-	total += count;
-
-	/* signature */
-	count = camel_data_wrapper_write_to_stream((CamelDataWrapper *)mps->signature, stream);
-	if (count == -1)
-		return -1;
-	total += count;
-
-	/* write the terminating boudary delimiter */
-	count = camel_stream_printf(stream, "\n--%s--\n", boundary);
-	if (count == -1)
-		return -1;
-	total += count;
-
-	/* and finally the postface */
-	if (mp->postface) {
-		count = camel_stream_write_string(stream, mp->postface);
-		if (count == -1)
-			return -1;
-		total += count;
-	}
+	return camel_multipart_signed_type;
+}
 
-	return total;
+/**
+ * camel_multipart_signed_new:
+ *
+ * Create a new #CamelMultipartSigned object.
+ *
+ * A MultipartSigned should be used to store and create parts of
+ * type "multipart/signed".  This is because multipart/signed is
+ * entirely broken-by-design (tm) and uses completely
+ * different semantics to other mutlipart types.  It must be treated
+ * as opaque data by any transport.  See rfc 3156 for details.
+ *
+ * There are 3 ways to create the part:
+ * Use construct_from_stream.  If this is used, then you must
+ * set the mime_type appropriately to match the data uses, so
+ * that the multiple parts my be extracted.
+ *
+ * Use construct_from_parser.  The parser MUST be in the #CAMEL_MIME_PARSER_STATE_HEADER
+ * state, and the current content_type MUST be "multipart/signed" with
+ * the appropriate boundary and it SHOULD include the appropriate protocol
+ * and hash specifiers.
+ *
+ * Use sign_part.  A signature part will automatically be created
+ * and the whole part may be written using write_to_stream to
+ * create a 'transport-safe' version (as safe as can be expected with
+ * such a broken specification).
+ *
+ * Returns: a new #CamelMultipartSigned object
+ **/
+CamelMultipartSigned *
+camel_multipart_signed_new (void)
+{
+	return (CamelMultipartSigned *)camel_object_new(CAMEL_MULTIPART_SIGNED_TYPE);
 }
 
 /**
@@ -579,33 +563,35 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
  * Returns: the signed content stream
  **/
 CamelStream *
-camel_multipart_signed_get_content_stream(CamelMultipartSigned *mps, CamelException *ex)
+camel_multipart_signed_get_content_stream (CamelMultipartSigned *mps,
+                                           CamelException *ex)
 {
 	CamelStream *constream;
 
 	/* we need to be able to verify stuff we just signed as well as stuff we loaded from a stream/parser */
 
 	if (mps->contentraw) {
-		constream = mps->contentraw;
-		camel_object_ref((CamelObject *)constream);
+		constream = camel_object_ref (mps->contentraw);
 	} else {
 		CamelStream *sub;
 		CamelMimeFilter *canon_filter;
 
-		if (mps->start1 == -1 && parse_content(mps) == -1) {
-			camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("parse error"));
+		if (mps->start1 == -1 && multipart_signed_parse_content(mps) == -1) {
+			camel_exception_setv (
+				ex, CAMEL_EXCEPTION_SYSTEM,
+				_("parse error"));
 			return NULL;
 		}
 
 		/* first, prepare our parts */
 		sub = camel_seekable_substream_new((CamelSeekableStream *)((CamelDataWrapper *)mps)->stream, mps->start1, mps->end1);
 		constream = camel_stream_filter_new (sub);
-		camel_object_unref((CamelObject *)sub);
+		camel_object_unref (sub);
 
 		/* Note: see rfc2015 or rfc3156, section 5 */
 		canon_filter = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_CRLF);
 		camel_stream_filter_add((CamelStreamFilter *)constream, (CamelMimeFilter *)canon_filter);
-		camel_object_unref((CamelObject *)canon_filter);
+		camel_object_unref (canon_filter);
 	}
 
 	return constream;
diff --git a/camel/camel-multipart-signed.h b/camel/camel-multipart-signed.h
index bad5a44..0931f14 100644
--- a/camel/camel-multipart-signed.h
+++ b/camel/camel-multipart-signed.h
@@ -85,7 +85,6 @@ typedef struct {
 	CamelMultipartClass parent_class;
 } CamelMultipartSignedClass;
 
-/* Standard Camel function */
 CamelType camel_multipart_signed_get_type (void);
 
 /* public methods */
diff --git a/camel/camel-multipart.c b/camel/camel-multipart.c
index eb2da00..87a43ed 100644
--- a/camel/camel-multipart.c
+++ b/camel/camel-multipart.c
@@ -38,89 +38,303 @@
 
 #define d(x)
 
-static gboolean              is_offline        (CamelDataWrapper *data_wrapper);
-static void                  add_part          (CamelMultipart *multipart,
-						CamelMimePart *part);
-static void                  add_part_at       (CamelMultipart *multipart,
-						CamelMimePart *part,
-						guint index);
-static void                  remove_part       (CamelMultipart *multipart,
-						CamelMimePart *part);
-static CamelMimePart *       remove_part_at    (CamelMultipart *multipart,
-						guint index);
-static CamelMimePart *       get_part          (CamelMultipart *multipart,
-						guint index);
-static guint                 get_number        (CamelMultipart *multipart);
-static void                  set_boundary      (CamelMultipart *multipart,
-						const gchar *boundary);
-static const gchar *         get_boundary      (CamelMultipart *multipart);
-static gssize               write_to_stream   (CamelDataWrapper *data_wrapper,
-						CamelStream *stream);
-
-static gint construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser *mp);
-
-static CamelDataWrapperClass *parent_class = NULL;
-
-/* Returns the class for a CamelMultipart */
-#define CMP_CLASS(so) CAMEL_MULTIPART_CLASS (CAMEL_OBJECT_GET_CLASS(so))
-
-/* Returns the class for a CamelDataWrapper */
-#define CDW_CLASS(so) CAMEL_DATA_WRAPPER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
+static gpointer camel_multipart_parent_class;
 
 static void
-camel_multipart_class_init (CamelMultipartClass *camel_multipart_class)
+multipart_finalize (CamelMultipart *multipart)
 {
-	CamelDataWrapperClass *camel_data_wrapper_class =
-		CAMEL_DATA_WRAPPER_CLASS (camel_multipart_class);
-
-	parent_class = (CamelDataWrapperClass *) camel_data_wrapper_get_type ();
-
-	/* virtual method definition */
-	camel_multipart_class->add_part = add_part;
-	camel_multipart_class->add_part_at = add_part_at;
-	camel_multipart_class->remove_part = remove_part;
-	camel_multipart_class->remove_part_at = remove_part_at;
-	camel_multipart_class->get_part = get_part;
-	camel_multipart_class->get_number = get_number;
-	camel_multipart_class->set_boundary = set_boundary;
-	camel_multipart_class->get_boundary = get_boundary;
-	camel_multipart_class->construct_from_parser = construct_from_parser;
-
-	/* virtual method overload */
-	camel_data_wrapper_class->write_to_stream = write_to_stream;
-	camel_data_wrapper_class->decode_to_stream = write_to_stream;
-	camel_data_wrapper_class->is_offline = is_offline;
+	g_list_foreach (multipart->parts, (GFunc) camel_object_unref, NULL);
+	g_list_free (multipart->parts);
+	multipart->parts = NULL;
+
+	g_free (multipart->preface);
+	g_free (multipart->postface);
+}
+
+/* this is MIME specific, doesn't belong here really */
+static gssize
+multipart_write_to_stream (CamelDataWrapper *data_wrapper,
+                           CamelStream *stream)
+{
+	CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper);
+	const gchar *boundary;
+	gssize total = 0;
+	gssize count;
+	GList *node;
+
+	/* get the bundary text */
+	boundary = camel_multipart_get_boundary (multipart);
+
+	/* we cannot write a multipart without a boundary string */
+	g_return_val_if_fail (boundary, -1);
+
+	/*
+	 * write the preface text (usually something like
+	 *   "This is a mime message, if you see this, then
+	 *    your mail client probably doesn't support ...."
+	 */
+	if (multipart->preface) {
+		count = camel_stream_write_string (stream, multipart->preface);
+		if (count == -1)
+			return -1;
+		total += count;
+	}
+
+	/*
+	 * Now, write all the parts, separated by the boundary
+	 * delimiter
+	 */
+	node = multipart->parts;
+	while (node) {
+		count = camel_stream_printf (
+			stream, "\n--%s\n", boundary);
+		if (count == -1)
+			return -1;
+		total += count;
+
+		count = camel_data_wrapper_write_to_stream (
+			CAMEL_DATA_WRAPPER (node->data), stream);
+		if (count == -1)
+			return -1;
+		total += count;
+		node = node->next;
+	}
+
+	/* write the terminating boudary delimiter */
+	count = camel_stream_printf (
+		stream, "\n--%s--\n", boundary);
+	if (count == -1)
+		return -1;
+	total += count;
+
+	/* and finally the postface */
+	if (multipart->postface) {
+		count = camel_stream_write_string (
+			stream, multipart->postface);
+		if (count == -1)
+			return -1;
+		total += count;
+	}
+
+	return total;
+}
+
+static gboolean
+multipart_is_offline (CamelDataWrapper *data_wrapper)
+{
+	CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper);
+	GList *node;
+	CamelDataWrapper *part;
+
+	if (CAMEL_DATA_WRAPPER_CLASS (camel_multipart_parent_class)->is_offline (data_wrapper))
+		return TRUE;
+	for (node = multipart->parts; node; node = node->next) {
+		part = node->data;
+		if (camel_data_wrapper_is_offline (part))
+			return TRUE;
+	}
+
+	return FALSE;
 }
 
 static void
-camel_multipart_init (gpointer object, gpointer klass)
+multipart_add_part (CamelMultipart *multipart,
+                    CamelMimePart *part)
 {
-	CamelMultipart *multipart = CAMEL_MULTIPART (object);
+	multipart->parts = g_list_append (
+		multipart->parts, camel_object_ref (part));
+}
 
-	camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (multipart),
-					  "multipart/mixed");
-	multipart->parts = NULL;
-	multipart->preface = NULL;
-	multipart->postface = NULL;
+static void
+multipart_add_part_at (CamelMultipart *multipart,
+                       CamelMimePart *part,
+                       guint index)
+{
+	multipart->parts = g_list_insert (
+		multipart->parts, camel_object_ref (part), index);
 }
 
 static void
-camel_multipart_finalize (CamelObject *object)
+multipart_remove_part (CamelMultipart *multipart,
+                       CamelMimePart *part)
 {
-	CamelMultipart *multipart = CAMEL_MULTIPART (object);
+	/* Make sure we don't unref a part we don't have. */
+	if (g_list_find (multipart->parts, part) == NULL)
+		return;
 
-	g_list_foreach (multipart->parts, (GFunc) camel_object_unref, NULL);
+	multipart->parts = g_list_remove (multipart->parts, part);
+	camel_object_unref (part);
+}
+
+static CamelMimePart *
+multipart_remove_part_at (CamelMultipart *multipart,
+                          guint index)
+{
+	CamelMimePart *removed_part;
+	GList *link;
+
+	if (!(multipart->parts))
+		return NULL;
 
-	if (multipart->parts)
-		g_list_free (multipart->parts);
+	link = g_list_nth (multipart->parts, index);
+	if (link == NULL) {
+		g_warning ("CamelMultipart::remove_part_at: "
+			   "part to remove is NULL\n");
+		return NULL;
+	}
+	removed_part = CAMEL_MIME_PART (link->data);
 
-	/*if (multipart->boundary)
-	  g_free (multipart->boundary);*/
+	multipart->parts = g_list_remove_link (multipart->parts, link);
+	if (link->data)
+		camel_object_unref (link->data);
+	g_list_free_1 (link);
 
-	if (multipart->preface)
-		g_free (multipart->preface);
-	if (multipart->postface)
-		g_free (multipart->postface);
+	return removed_part;
+}
+
+static CamelMimePart *
+multipart_get_part (CamelMultipart *multipart,
+                    guint index)
+{
+	GList *part;
+
+	if (!(multipart->parts))
+		return NULL;
+
+	part = g_list_nth (multipart->parts, index);
+	if (part)
+		return CAMEL_MIME_PART (part->data);
+	else
+		return NULL;
+}
+
+static guint
+multipart_get_number (CamelMultipart *multipart)
+{
+	return g_list_length (multipart->parts);
+}
+
+static void
+multipart_set_boundary (CamelMultipart *multipart,
+                        const gchar *boundary)
+{
+	CamelDataWrapper *cdw = CAMEL_DATA_WRAPPER (multipart);
+	gchar *bgen, bbuf[27], *p;
+	guint8 *digest;
+	gsize length;
+	gint state, save;
+
+	g_return_if_fail (cdw->mime_type != NULL);
+
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
+	if (!boundary) {
+		GChecksum *checksum;
+
+		/* Generate a fairly random boundary string. */
+		bgen = g_strdup_printf ("%p:%lu:%lu", (gpointer) multipart,
+					(gulong) getpid(),
+					(gulong) time(NULL));
+
+		checksum = g_checksum_new (G_CHECKSUM_MD5);
+		g_checksum_update (checksum, (guchar *) bgen, -1);
+		g_checksum_get_digest (checksum, digest, &length);
+		g_checksum_free (checksum);
+
+		g_free (bgen);
+		strcpy (bbuf, "=-");
+		p = bbuf + 2;
+		state = save = 0;
+		p += g_base64_encode_step (
+			(guchar *) digest, length, FALSE, p, &state, &save);
+		*p = '\0';
+
+		boundary = bbuf;
+	}
+
+	camel_content_type_set_param (cdw->mime_type, "boundary", boundary);
+}
+
+static const gchar *
+multipart_get_boundary (CamelMultipart *multipart)
+{
+	CamelDataWrapper *cdw = CAMEL_DATA_WRAPPER (multipart);
+
+	g_return_val_if_fail (cdw->mime_type != NULL, NULL);
+	return camel_content_type_param (cdw->mime_type, "boundary");
+}
+
+static gint
+multipart_construct_from_parser (CamelMultipart *multipart,
+                                 CamelMimeParser *mp)
+{
+	gint err;
+	CamelContentType *content_type;
+	CamelMimePart *bodypart;
+	gchar *buf;
+	gsize len;
+
+	g_assert(camel_mime_parser_state(mp) == CAMEL_MIME_PARSER_STATE_MULTIPART);
+
+	/* FIXME: we should use a came-mime-mutlipart, not jsut a camel-multipart, but who cares */
+	d(printf("Creating multi-part\n"));
+
+	content_type = camel_mime_parser_content_type(mp);
+	camel_multipart_set_boundary(multipart,
+				     camel_content_type_param(content_type, "boundary"));
+
+	while (camel_mime_parser_step(mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_MULTIPART_END) {
+		camel_mime_parser_unstep(mp);
+		bodypart = camel_mime_part_new();
+		camel_mime_part_construct_from_parser (bodypart, mp);
+		camel_multipart_add_part(multipart, bodypart);
+		camel_object_unref (bodypart);
+	}
+
+	/* these are only return valid data in the MULTIPART_END state */
+	camel_multipart_set_preface(multipart, camel_mime_parser_preface (mp));
+	camel_multipart_set_postface(multipart, camel_mime_parser_postface (mp));
+
+	err = camel_mime_parser_errno(mp);
+	if (err != 0) {
+		errno = err;
+		return -1;
+	} else
+		return 0;
+}
+
+static void
+camel_multipart_class_init (CamelMultipartClass *class)
+{
+	CamelDataWrapperClass *data_wrapper_class;
+
+	camel_multipart_parent_class = (CamelDataWrapperClass *) camel_data_wrapper_get_type ();
+
+	data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (class);
+	data_wrapper_class->write_to_stream = multipart_write_to_stream;
+	data_wrapper_class->decode_to_stream = multipart_write_to_stream;
+	data_wrapper_class->is_offline = multipart_is_offline;
+
+	class->add_part = multipart_add_part;
+	class->add_part_at = multipart_add_part_at;
+	class->remove_part = multipart_remove_part;
+	class->remove_part_at = multipart_remove_part_at;
+	class->get_part = multipart_get_part;
+	class->get_number = multipart_get_number;
+	class->set_boundary = multipart_set_boundary;
+	class->get_boundary = multipart_get_boundary;
+	class->construct_from_parser = multipart_construct_from_parser;
+}
+
+static void
+camel_multipart_init (CamelMultipart *multipart)
+{
+	camel_data_wrapper_set_mime_type (
+		CAMEL_DATA_WRAPPER (multipart), "multipart/mixed");
+	multipart->parts = NULL;
+	multipart->preface = NULL;
+	multipart->postface = NULL;
 }
 
 CamelType
@@ -135,7 +349,7 @@ camel_multipart_get_type (void)
 							    (CamelObjectClassInitFunc) camel_multipart_class_init,
 							    NULL,
 							    (CamelObjectInitFunc) camel_multipart_init,
-							    (CamelObjectFinalizeFunc) camel_multipart_finalize);
+							    (CamelObjectFinalizeFunc) multipart_finalize);
 	}
 
 	return camel_multipart_type;
@@ -160,13 +374,6 @@ camel_multipart_new (void)
 	return multipart;
 }
 
-static void
-add_part (CamelMultipart *multipart, CamelMimePart *part)
-{
-	multipart->parts = g_list_append (multipart->parts, part);
-	camel_object_ref (part);
-}
-
 /**
  * camel_multipart_add_part:
  * @multipart: a #CamelMultipart object
@@ -175,19 +382,18 @@ add_part (CamelMultipart *multipart, CamelMimePart *part)
  * Appends the part to the multipart object.
  **/
 void
-camel_multipart_add_part (CamelMultipart *multipart, CamelMimePart *part)
+camel_multipart_add_part (CamelMultipart *multipart,
+                          CamelMimePart *part)
 {
+	CamelMultipartClass *class;
+
 	g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
 	g_return_if_fail (CAMEL_IS_MIME_PART (part));
 
-	CMP_CLASS (multipart)->add_part (multipart, part);
-}
+	class = CAMEL_MULTIPART_GET_CLASS (multipart);
+	g_return_if_fail (class->add_part != NULL);
 
-static void
-add_part_at (CamelMultipart *multipart, CamelMimePart *part, guint index)
-{
-	multipart->parts = g_list_insert (multipart->parts, part, index);
-	camel_object_ref (part);
+	class->add_part (multipart, part);
 }
 
 /**
@@ -202,21 +408,18 @@ add_part_at (CamelMultipart *multipart, CamelMimePart *part, guint index)
  **/
 void
 camel_multipart_add_part_at (CamelMultipart *multipart,
-			     CamelMimePart *part, guint index)
+                             CamelMimePart *part,
+                             guint index)
 {
+	CamelMultipartClass *class;
+
 	g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
 	g_return_if_fail (CAMEL_IS_MIME_PART (part));
 
-	CMP_CLASS (multipart)->add_part_at (multipart, part, index);
-}
+	class = CAMEL_MULTIPART_GET_CLASS (multipart);
+	g_return_if_fail (class->add_part_at != NULL);
 
-static void
-remove_part (CamelMultipart *multipart, CamelMimePart *part)
-{
-	if (!multipart->parts)
-		return;
-	multipart->parts = g_list_remove (multipart->parts, part);
-	camel_object_unref (part);
+	class->add_part_at (multipart, part, index);
 }
 
 /**
@@ -228,39 +431,17 @@ remove_part (CamelMultipart *multipart, CamelMimePart *part)
  **/
 void
 camel_multipart_remove_part (CamelMultipart *multipart,
-			     CamelMimePart *part)
+                             CamelMimePart *part)
 {
+	CamelMultipartClass *class;
+
 	g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
 	g_return_if_fail (CAMEL_IS_MIME_PART (part));
 
-	CMP_CLASS (multipart)->remove_part (multipart, part);
-}
-
-static CamelMimePart *
-remove_part_at (CamelMultipart *multipart, guint index)
-{
-	GList *parts_list;
-	GList *part_to_remove;
-	CamelMimePart *removed_part;
-
-	if (!(multipart->parts))
-		return NULL;
-
-	parts_list = multipart->parts;
-	part_to_remove = g_list_nth (parts_list, index);
-	if (!part_to_remove) {
-		g_warning ("CamelMultipart::remove_part_at: "
-			   "part to remove is NULL\n");
-		return NULL;
-	}
-	removed_part = CAMEL_MIME_PART (part_to_remove->data);
-
-	multipart->parts = g_list_remove_link (parts_list, part_to_remove);
-	if (part_to_remove->data)
-		camel_object_unref (part_to_remove->data);
-	g_list_free_1 (part_to_remove);
+	class = CAMEL_MULTIPART_GET_CLASS (multipart);
+	g_return_if_fail (class->remove_part != NULL);
 
-	return removed_part;
+	class->remove_part (multipart, part);
 }
 
 /**
@@ -274,26 +455,17 @@ remove_part_at (CamelMultipart *multipart, guint index)
  * before being returned, which may cause it to be destroyed.
  **/
 CamelMimePart *
-camel_multipart_remove_part_at (CamelMultipart *multipart, guint index)
+camel_multipart_remove_part_at (CamelMultipart *multipart,
+                                guint index)
 {
-	g_return_val_if_fail (CAMEL_IS_MULTIPART (multipart), NULL);
-
-	return CMP_CLASS (multipart)->remove_part_at (multipart, index);
-}
+	CamelMultipartClass *class;
 
-static CamelMimePart *
-get_part (CamelMultipart *multipart, guint index)
-{
-	GList *part;
+	g_return_val_if_fail (CAMEL_IS_MULTIPART (multipart), NULL);
 
-	if (!(multipart->parts))
-		return NULL;
+	class = CAMEL_MULTIPART_GET_CLASS (multipart);
+	g_return_val_if_fail (class->remove_part_at != NULL, NULL);
 
-	part = g_list_nth (multipart->parts, index);
-	if (part)
-		return CAMEL_MIME_PART (part->data);
-	else
-		return NULL;
+	return class->remove_part_at (multipart, index);
 }
 
 /**
@@ -304,17 +476,17 @@ get_part (CamelMultipart *multipart, guint index)
  * Returns: the indicated subpart, or %NULL
  **/
 CamelMimePart *
-camel_multipart_get_part (CamelMultipart *multipart, guint index)
+camel_multipart_get_part (CamelMultipart *multipart,
+                          guint index)
 {
+	CamelMultipartClass *class;
+
 	g_return_val_if_fail (CAMEL_IS_MULTIPART (multipart), NULL);
 
-	return CMP_CLASS (multipart)->get_part (multipart, index);
-}
+	class = CAMEL_MULTIPART_GET_CLASS (multipart);
+	g_return_val_if_fail (class->get_part != NULL, NULL);
 
-static guint
-get_number (CamelMultipart *multipart)
-{
-	return g_list_length (multipart->parts);
+	return class->get_part (multipart, index);
 }
 
 /**
@@ -326,50 +498,14 @@ get_number (CamelMultipart *multipart)
 guint
 camel_multipart_get_number (CamelMultipart *multipart)
 {
-	g_return_val_if_fail (CAMEL_IS_MULTIPART (multipart), 0);
+	CamelMultipartClass *class;
 
-	return CMP_CLASS (multipart)->get_number (multipart);
-}
-
-static void
-set_boundary (CamelMultipart *multipart, const gchar *boundary)
-{
-	CamelDataWrapper *cdw = CAMEL_DATA_WRAPPER (multipart);
-	gchar *bgen, bbuf[27], *p;
-	guint8 *digest;
-	gsize length;
-	gint state, save;
-
-	g_return_if_fail (cdw->mime_type != NULL);
-
-	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
-	digest = g_alloca (length);
-
-	if (!boundary) {
-		GChecksum *checksum;
-
-		/* Generate a fairly random boundary string. */
-		bgen = g_strdup_printf ("%p:%lu:%lu", (gpointer) multipart,
-					(gulong) getpid(),
-					(gulong) time(NULL));
-
-		checksum = g_checksum_new (G_CHECKSUM_MD5);
-		g_checksum_update (checksum, (guchar *) bgen, -1);
-		g_checksum_get_digest (checksum, digest, &length);
-		g_checksum_free (checksum);
-
-		g_free (bgen);
-		strcpy (bbuf, "=-");
-		p = bbuf + 2;
-		state = save = 0;
-		p += g_base64_encode_step (
-			(guchar *) digest, length, FALSE, p, &state, &save);
-		*p = '\0';
+	g_return_val_if_fail (CAMEL_IS_MULTIPART (multipart), 0);
 
-		boundary = bbuf;
-	}
+	class = CAMEL_MULTIPART_GET_CLASS (multipart);
+	g_return_val_if_fail (class->get_number != NULL, 0);
 
-	camel_content_type_set_param (cdw->mime_type, "boundary", boundary);
+	return class->get_number (multipart);
 }
 
 /**
@@ -383,20 +519,17 @@ set_boundary (CamelMultipart *multipart, const gchar *boundary)
  * be used.
  **/
 void
-camel_multipart_set_boundary (CamelMultipart *multipart, const gchar *boundary)
+camel_multipart_set_boundary (CamelMultipart *multipart,
+                              const gchar *boundary)
 {
-	g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
+	CamelMultipartClass *class;
 
-	CMP_CLASS (multipart)->set_boundary (multipart, boundary);
-}
+	g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
 
-static const gchar *
-get_boundary (CamelMultipart *multipart)
-{
-	CamelDataWrapper *cdw = CAMEL_DATA_WRAPPER (multipart);
+	class = CAMEL_MULTIPART_GET_CLASS (multipart);
+	g_return_if_fail (class->set_boundary != NULL);
 
-	g_return_val_if_fail (cdw->mime_type != NULL, NULL);
-	return camel_content_type_param (cdw->mime_type, "boundary");
+	class->set_boundary (multipart, boundary);
 }
 
 /**
@@ -408,88 +541,14 @@ get_boundary (CamelMultipart *multipart)
 const gchar *
 camel_multipart_get_boundary (CamelMultipart *multipart)
 {
-	return CMP_CLASS (multipart)->get_boundary (multipart);
-}
+	CamelMultipartClass *class;
 
-static gboolean
-is_offline (CamelDataWrapper *data_wrapper)
-{
-	CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper);
-	GList *node;
-	CamelDataWrapper *part;
-
-	if (parent_class->is_offline (data_wrapper))
-		return TRUE;
-	for (node = multipart->parts; node; node = node->next) {
-		part = node->data;
-		if (camel_data_wrapper_is_offline (part))
-			return TRUE;
-	}
-
-	return FALSE;
-}
-
-/* this is MIME specific, doesn't belong here really */
-static gssize
-write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
-{
-	CamelMultipart *multipart = CAMEL_MULTIPART (data_wrapper);
-	const gchar *boundary;
-	gssize total = 0;
-	gssize count;
-	GList *node;
-
-	/* get the bundary text */
-	boundary = camel_multipart_get_boundary (multipart);
-
-	/* we cannot write a multipart without a boundary string */
-	g_return_val_if_fail (boundary, -1);
-
-	/*
-	 * write the preface text (usually something like
-	 *   "This is a mime message, if you see this, then
-	 *    your mail client probably doesn't support ...."
-	 */
-	if (multipart->preface) {
-		count = camel_stream_write_string (stream, multipart->preface);
-		if (count == -1)
-			return -1;
-		total += count;
-	}
-
-	/*
-	 * Now, write all the parts, separated by the boundary
-	 * delimiter
-	 */
-	node = multipart->parts;
-	while (node) {
-		count = camel_stream_printf (stream, "\n--%s\n", boundary);
-		if (count == -1)
-			return -1;
-		total += count;
-
-		count = camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (node->data), stream);
-		if (count == -1)
-			return -1;
-		total += count;
-		node = node->next;
-	}
-
-	/* write the terminating boudary delimiter */
-	count = camel_stream_printf (stream, "\n--%s--\n", boundary);
-	if (count == -1)
-		return -1;
-	total += count;
+	g_return_val_if_fail (CAMEL_IS_MULTIPART (multipart), NULL);
 
-	/* and finally the postface */
-	if (multipart->postface) {
-		count = camel_stream_write_string (stream, multipart->postface);
-		if (count == -1)
-			return -1;
-		total += count;
-	}
+	class = CAMEL_MULTIPART_GET_CLASS (multipart);
+	g_return_val_if_fail (class->get_boundary != NULL, NULL);
 
-	return total;
+	return class->get_boundary (multipart);
 }
 
 /**
@@ -502,15 +561,16 @@ write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
  * be relatively short, and will be ignored by any MIME mail client.
  **/
 void
-camel_multipart_set_preface(CamelMultipart *multipart, const gchar *preface)
+camel_multipart_set_preface (CamelMultipart *multipart,
+                             const gchar *preface)
 {
-	if (multipart->preface != preface) {
-		g_free(multipart->preface);
-		if (preface)
-			multipart->preface = g_strdup(preface);
-		else
-			multipart->preface = NULL;
-	}
+	g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
+
+	if (multipart->preface == preface)
+		return;
+
+	g_free (multipart->preface);
+	multipart->preface = g_strdup (preface);
 }
 
 /**
@@ -525,53 +585,16 @@ camel_multipart_set_preface(CamelMultipart *multipart, const gchar *preface)
  * Generally postface texts should not be sent with multipart messages.
  **/
 void
-camel_multipart_set_postface(CamelMultipart *multipart, const gchar *postface)
+camel_multipart_set_postface (CamelMultipart *multipart,
+                              const gchar *postface)
 {
-	if (multipart->postface != postface) {
-		g_free(multipart->postface);
-		if (postface)
-			multipart->postface = g_strdup(postface);
-		else
-			multipart->postface = NULL;
-	}
-}
-
-static gint
-construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser *mp)
-{
-	gint err;
-	CamelContentType *content_type;
-	CamelMimePart *bodypart;
-	gchar *buf;
-	gsize len;
-
-	g_assert(camel_mime_parser_state(mp) == CAMEL_MIME_PARSER_STATE_MULTIPART);
-
-	/* FIXME: we should use a came-mime-mutlipart, not jsut a camel-multipart, but who cares */
-	d(printf("Creating multi-part\n"));
-
-	content_type = camel_mime_parser_content_type(mp);
-	camel_multipart_set_boundary(multipart,
-				     camel_content_type_param(content_type, "boundary"));
-
-	while (camel_mime_parser_step(mp, &buf, &len) != CAMEL_MIME_PARSER_STATE_MULTIPART_END) {
-		camel_mime_parser_unstep(mp);
-		bodypart = camel_mime_part_new();
-		camel_mime_part_construct_from_parser(bodypart, mp);
-		camel_multipart_add_part(multipart, bodypart);
-		camel_object_unref((CamelObject *)bodypart);
-	}
+	g_return_if_fail (CAMEL_IS_MULTIPART (multipart));
 
-	/* these are only return valid data in the MULTIPART_END state */
-	camel_multipart_set_preface(multipart, camel_mime_parser_preface (mp));
-	camel_multipart_set_postface(multipart, camel_mime_parser_postface (mp));
+	if (multipart->postface == postface)
+		return;
 
-	err = camel_mime_parser_errno(mp);
-	if (err != 0) {
-		errno = err;
-		return -1;
-	} else
-		return 0;
+	g_free (multipart->postface);
+	multipart->postface = g_strdup (postface);
 }
 
 /**
@@ -584,9 +607,16 @@ construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser *mp)
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_multipart_construct_from_parser(CamelMultipart *multipart, struct _CamelMimeParser *mp)
+camel_multipart_construct_from_parser (CamelMultipart *multipart,
+                                       CamelMimeParser *mp)
 {
-	g_return_val_if_fail(CAMEL_IS_MULTIPART(multipart), -1);
+	CamelMultipartClass *class;
+
+	g_return_val_if_fail (CAMEL_IS_MULTIPART(multipart), -1);
+	g_return_val_if_fail (CAMEL_IS_MIME_PARSER (mp), -1);
+
+	class = CAMEL_MULTIPART_GET_CLASS (multipart);
+	g_return_val_if_fail (class->construct_from_parser != NULL, -1);
 
-	return CMP_CLASS(multipart)->construct_from_parser(multipart, mp);
+	return class->construct_from_parser (multipart, mp);
 }
diff --git a/camel/camel-multipart.h b/camel/camel-multipart.h
index 8d464c0..79b34ad 100644
--- a/camel/camel-multipart.h
+++ b/camel/camel-multipart.h
@@ -36,6 +36,8 @@
 #define CAMEL_MULTIPART(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_MULTIPART_TYPE, CamelMultipart))
 #define CAMEL_MULTIPART_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_MULTIPART_TYPE, CamelMultipartClass))
 #define CAMEL_IS_MULTIPART(o)    (CAMEL_CHECK_TYPE((o), CAMEL_MULTIPART_TYPE))
+#define CAMEL_MULTIPART_GET_CLASS(obj) \
+	((CamelMultipartClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
diff --git a/camel/camel-object.c b/camel/camel-object.c
index aee83d4..a45dfa0 100644
--- a/camel/camel-object.c
+++ b/camel/camel-object.c
@@ -670,8 +670,8 @@ camel_object_new(CamelType type)
 	return o;
 }
 
-void
-camel_object_ref(gpointer vo)
+gpointer
+camel_object_ref (gpointer vo)
 {
 	register CamelObject *o = vo;
 
@@ -683,10 +683,12 @@ camel_object_ref(gpointer vo)
 	d(printf("%p: ref %s(%d)\n", o, o->klass->name, o->ref_count));
 
 	REF_UNLOCK();
+
+	return vo;
 }
 
 void
-camel_object_unref(gpointer vo)
+camel_object_unref (gpointer vo)
 {
 	register CamelObject *o = vo;
 	register CamelObjectClass *klass, *k;
@@ -1204,7 +1206,7 @@ trigger:
 
 trigger_interface:
 	/* lock the object for hook emission */
-	camel_object_ref(obj);
+	camel_object_ref (obj);
 	hooks = camel_object_get_hooks(obj);
 
 	if (hooks->list) {
@@ -1247,7 +1249,7 @@ trigger_interface:
 	}
 
 	camel_object_unget_hooks(obj);
-	camel_object_unref(obj);
+	camel_object_unref (obj);
 }
 
 /* get/set arg methods */
diff --git a/camel/camel-object.h b/camel/camel-object.h
index 3a034d1..8b8ed08 100644
--- a/camel/camel-object.h
+++ b/camel/camel-object.h
@@ -198,13 +198,8 @@ CamelType camel_object_get_type (void);
 
 CamelObject *camel_object_new (CamelType type);
 
-void camel_object_ref(gpointer);
-void camel_object_unref(gpointer);
-
-#ifdef CAMEL_DEBUG
-#define camel_object_ref(o) (printf("%s (%s:%d):ref (%p)\n", __FUNCTION__, __FILE__, __LINE__, o), camel_object_ref(o))
-#define camel_object_unref(o) (printf("%s (%s:%d):unref (%p)\n", __FUNCTION__, __FILE__, __LINE__, o), camel_object_unref (o))
-#endif
+gpointer camel_object_ref (gpointer);
+void camel_object_unref (gpointer);
 
 /* hooks */
 CamelObjectHookID camel_object_hook_event(gpointer obj, const gchar *name, CamelObjectEventHookFunc hook, gpointer data);
diff --git a/camel/camel-offline-folder.c b/camel/camel-offline-folder.c
index a8d941e..f17eded 100644
--- a/camel/camel-offline-folder.c
+++ b/camel/camel-offline-folder.c
@@ -24,7 +24,6 @@
 #include <config.h>
 #endif
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 
 #include "camel-offline-folder.h"
@@ -32,18 +31,7 @@
 #include "camel-service.h"
 #include "camel-session.h"
 
-#define CAMEL_OFFLINE_FOLDER_GET_CLASS(f) (CAMEL_OFFLINE_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (f)))
-
-static void camel_offline_folder_class_init (CamelOfflineFolderClass *klass);
-static void camel_offline_folder_init (CamelOfflineFolder *folder, CamelOfflineFolderClass *klass);
-static void camel_offline_folder_finalize (CamelObject *object);
-
-static gint offline_folder_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args);
-static gint offline_folder_setv (CamelObject *object, CamelException *ex, CamelArgV *args);
-
-static void offline_folder_downsync (CamelOfflineFolder *offline, const gchar *expression, CamelException *ex);
-
-static CamelFolderClass *parent_class = NULL;
+static gpointer camel_offline_folder_parent_class;
 
 static GSList *offline_folder_props = NULL;
 
@@ -51,45 +39,6 @@ static CamelProperty offline_prop_list[] = {
 	{ CAMEL_OFFLINE_FOLDER_SYNC_OFFLINE, "sync_offline", N_("Copy folder content locally for offline operation") },
 };
 
-CamelType
-camel_offline_folder_get_type (void)
-{
-	static CamelType type = NULL;
-
-	if (!type) {
-		type = camel_type_register (CAMEL_FOLDER_TYPE,
-					    "CamelOfflineFolder",
-					    sizeof (CamelOfflineFolder),
-					    sizeof (CamelOfflineFolderClass),
-					    (CamelObjectClassInitFunc) camel_offline_folder_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_offline_folder_init,
-					    (CamelObjectFinalizeFunc) camel_offline_folder_finalize);
-	}
-
-	return type;
-}
-
-static void
-camel_offline_folder_class_init (CamelOfflineFolderClass *klass)
-{
-	gint i;
-
-	parent_class = (CamelFolderClass *) camel_type_get_global_classfuncs (CAMEL_FOLDER_TYPE);
-
-	if (offline_folder_props == NULL) {
-		for (i = 0; i < G_N_ELEMENTS (offline_prop_list); i++) {
-			offline_prop_list[i].description = _(offline_prop_list[i].description);
-			offline_folder_props = g_slist_prepend (offline_folder_props, &offline_prop_list[i]);
-		}
-	}
-
-	((CamelObjectClass *) klass)->getv = offline_folder_getv;
-	((CamelObjectClass *) klass)->setv = offline_folder_setv;
-
-	klass->downsync = offline_folder_downsync;
-}
-
 struct _offline_downsync_msg {
 	CamelSessionThreadMsg msg;
 
@@ -150,27 +99,16 @@ offline_folder_changed (CamelFolder *folder, CamelFolderChangeInfo *changes, gpo
 		m = camel_session_thread_msg_new (session, &offline_downsync_ops, sizeof (*m));
 		m->changes = camel_folder_change_info_new ();
 		camel_folder_change_info_cat (m->changes, changes);
-		camel_object_ref (folder);
-		m->folder = folder;
+		m->folder = camel_object_ref (folder);
 
 		camel_session_thread_queue (session, &m->msg, 0);
 	}
 }
 
-static void
-camel_offline_folder_init (CamelOfflineFolder *folder, CamelOfflineFolderClass *klass)
-{
-	camel_object_hook_event (folder, "folder_changed", (CamelObjectEventHookFunc) offline_folder_changed, NULL);
-}
-
-static void
-camel_offline_folder_finalize (CamelObject *object)
-{
-	;
-}
-
 static gint
-offline_folder_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
+offline_folder_getv (CamelObject *object,
+                     CamelException *ex,
+                     CamelArgGetV *args)
 {
 	CamelArgGetV props;
 	gint i, count = 0;
@@ -186,7 +124,7 @@ offline_folder_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args
 		case CAMEL_FOLDER_ARG_PROPERTIES:
 			props.argc = 1;
 			props.argv[0] = *arg;
-			((CamelObjectClass *) parent_class)->getv (object, ex, &props);
+			((CamelObjectClass *) camel_offline_folder_parent_class)->getv (object, ex, &props);
 			*arg->ca_ptr = g_slist_concat (*arg->ca_ptr, g_slist_copy (offline_folder_props));
 			break;
 		case CAMEL_OFFLINE_FOLDER_ARG_SYNC_OFFLINE:
@@ -201,13 +139,15 @@ offline_folder_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args
 	}
 
 	if (count)
-		return ((CamelObjectClass *) parent_class)->getv (object, ex, args);
+		return ((CamelObjectClass *) camel_offline_folder_parent_class)->getv (object, ex, args);
 
 	return 0;
 }
 
 static gint
-offline_folder_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
+offline_folder_setv (CamelObject *object,
+                     CamelException *ex,
+                     CamelArgV *args)
 {
 	CamelOfflineFolder *folder = (CamelOfflineFolder *) object;
 	gboolean save = FALSE;
@@ -236,11 +176,13 @@ offline_folder_setv (CamelObject *object, CamelException *ex, CamelArgV *args)
 	if (save)
 		camel_object_state_write (object);
 
-	return ((CamelObjectClass *) parent_class)->setv (object, ex, args);
+	return ((CamelObjectClass *) camel_offline_folder_parent_class)->setv (object, ex, args);
 }
 
 static void
-offline_folder_downsync (CamelOfflineFolder *offline, const gchar *expression, CamelException *ex)
+offline_folder_downsync (CamelOfflineFolder *offline,
+                         const gchar *expression,
+                         CamelException *ex)
 {
 	CamelFolder *folder = (CamelFolder *) offline;
 	GPtrArray *uids, *uncached_uids = NULL;
@@ -279,6 +221,55 @@ done:
 	camel_operation_end (NULL);
 }
 
+static void
+camel_offline_folder_class_init (CamelOfflineFolderClass *class)
+{
+	CamelObjectClass *camel_object_class;
+	gint ii;
+
+	camel_offline_folder_parent_class = (CamelFolderClass *) camel_type_get_global_classfuncs (CAMEL_FOLDER_TYPE);
+
+	camel_object_class = CAMEL_OBJECT_CLASS (class);
+	camel_object_class->getv = offline_folder_getv;
+	camel_object_class->setv = offline_folder_setv;
+
+	class->downsync = offline_folder_downsync;
+
+	for (ii = 0; ii < G_N_ELEMENTS (offline_prop_list); ii++) {
+		offline_prop_list[ii].description =
+			_(offline_prop_list[ii].description);
+		offline_folder_props = g_slist_prepend (
+			offline_folder_props, &offline_prop_list[ii]);
+	}
+}
+
+static void
+camel_offline_folder_init (CamelOfflineFolder *folder)
+{
+	camel_object_hook_event (
+		folder, "folder_changed",
+		(CamelObjectEventHookFunc) offline_folder_changed, NULL);
+}
+
+CamelType
+camel_offline_folder_get_type (void)
+{
+	static CamelType type = NULL;
+
+	if (!type) {
+		type = camel_type_register (CAMEL_FOLDER_TYPE,
+					    "CamelOfflineFolder",
+					    sizeof (CamelOfflineFolder),
+					    sizeof (CamelOfflineFolderClass),
+					    (CamelObjectClassInitFunc) camel_offline_folder_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_offline_folder_init,
+					    (CamelObjectFinalizeFunc) NULL);
+	}
+
+	return type;
+}
+
 /**
  * camel_offline_folder_downsync:
  * @offline: a #CamelOfflineFolder object
@@ -289,9 +280,16 @@ done:
  * the local machine for offline availability.
  **/
 void
-camel_offline_folder_downsync (CamelOfflineFolder *offline, const gchar *expression, CamelException *ex)
+camel_offline_folder_downsync (CamelOfflineFolder *offline,
+                               const gchar *expression,
+                               CamelException *ex)
 {
+	CamelOfflineFolderClass *class;
+
 	g_return_if_fail (CAMEL_IS_OFFLINE_FOLDER (offline));
 
-	CAMEL_OFFLINE_FOLDER_GET_CLASS (offline)->downsync (offline, expression, ex);
+	class = CAMEL_OFFLINE_FOLDER_GET_CLASS (offline);
+	g_return_if_fail (class->downsync != NULL);
+
+	class->downsync (offline, expression, ex);
 }
diff --git a/camel/camel-offline-folder.h b/camel/camel-offline-folder.h
index 7a907e9..cabeff1 100644
--- a/camel/camel-offline-folder.h
+++ b/camel/camel-offline-folder.h
@@ -33,6 +33,8 @@
 #define CAMEL_OFFLINE_FOLDER(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_OFFLINE_FOLDER_TYPE, CamelOfflineFolder))
 #define CAMEL_OFFLINE_FOLDER_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_OFFLINE_FOLDER_TYPE, CamelOfflineFolderClass))
 #define CAMEL_IS_OFFLINE_FOLDER(o)    (CAMEL_CHECK_TYPE((o), CAMEL_OFFLINE_FOLDER_TYPE))
+#define CAMEL_OFFLINE_FOLDER_GET_CLASS(obj) \
+	((CamelOfflineFolderClass *) CAMEL_OBJECT_GET_CLASS (obj))
 
 G_BEGIN_DECLS
 
diff --git a/camel/camel-offline-journal.c b/camel/camel-offline-journal.c
index 8c6952f..34b6014 100644
--- a/camel/camel-offline-journal.c
+++ b/camel/camel-offline-journal.c
@@ -33,7 +33,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
 
@@ -46,29 +45,17 @@
 
 #define d(x)
 
-static void camel_offline_journal_class_init (CamelOfflineJournalClass *klass);
-static void camel_offline_journal_init (CamelOfflineJournal *journal, CamelOfflineJournalClass *klass);
-static void camel_offline_journal_finalize (CamelObject *object);
-
 static CamelObjectClass *parent_class = NULL;
 
-CamelType
-camel_offline_journal_get_type (void)
+static void
+offline_journal_finalize (CamelOfflineJournal *journal)
 {
-	static CamelType type = NULL;
+	CamelDListNode *entry;
 
-	if (!type) {
-		type = camel_type_register (camel_object_get_type (),
-					    "CamelOfflineJournal",
-					    sizeof (CamelOfflineJournal),
-					    sizeof (CamelOfflineJournalClass),
-					    (CamelObjectClassInitFunc) camel_offline_journal_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_offline_journal_init,
-					    (CamelObjectFinalizeFunc) camel_offline_journal_finalize);
-	}
+	g_free (journal->filename);
 
-	return type;
+	while ((entry = camel_dlist_remhead (&journal->queue)))
+		CAMEL_OFFLINE_JOURNAL_GET_CLASS (journal)->entry_free (journal, entry);
 }
 
 static void
@@ -78,23 +65,30 @@ camel_offline_journal_class_init (CamelOfflineJournalClass *klass)
 }
 
 static void
-camel_offline_journal_init (CamelOfflineJournal *journal, CamelOfflineJournalClass *klass)
+camel_offline_journal_init (CamelOfflineJournal *journal)
 {
 	journal->folder = NULL;
 	journal->filename = NULL;
 	camel_dlist_init (&journal->queue);
 }
 
-static void
-camel_offline_journal_finalize (CamelObject *object)
+CamelType
+camel_offline_journal_get_type (void)
 {
-	CamelOfflineJournal *journal = (CamelOfflineJournal *) object;
-	CamelDListNode *entry;
+	static CamelType type = NULL;
 
-	g_free (journal->filename);
+	if (!type) {
+		type = camel_type_register (camel_object_get_type (),
+					    "CamelOfflineJournal",
+					    sizeof (CamelOfflineJournal),
+					    sizeof (CamelOfflineJournalClass),
+					    (CamelObjectClassInitFunc) camel_offline_journal_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_offline_journal_init,
+					    (CamelObjectFinalizeFunc) offline_journal_finalize);
+	}
 
-	while ((entry = camel_dlist_remhead (&journal->queue)))
-		CAMEL_OFFLINE_JOURNAL_GET_CLASS (journal)->entry_free (journal, entry);
+	return type;
 }
 
 /**
@@ -148,16 +142,18 @@ camel_offline_journal_set_filename (CamelOfflineJournal *journal, const gchar *f
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_offline_journal_write (CamelOfflineJournal *journal, CamelException *ex)
+camel_offline_journal_write (CamelOfflineJournal *journal,
+                             CamelException *ex)
 {
 	CamelDListNode *entry;
 	FILE *fp;
 	gint fd;
 
 	if ((fd = g_open (journal->filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) == -1) {
-		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
-				      _("Cannot write offline journal for folder '%s': %s"),
-				      journal->folder->full_name, g_strerror (errno));
+		camel_exception_setv (
+			ex, CAMEL_EXCEPTION_SYSTEM,
+			_("Cannot write offline journal for folder '%s': %s"),
+			journal->folder->full_name, g_strerror (errno));
 		return -1;
 	}
 
@@ -178,9 +174,10 @@ camel_offline_journal_write (CamelOfflineJournal *journal, CamelException *ex)
 
  exception:
 
-	camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
-			      _("Cannot write offline journal for folder '%s': %s"),
-			      journal->folder->full_name, g_strerror (errno));
+	camel_exception_setv (
+		ex, CAMEL_EXCEPTION_SYSTEM,
+		_("Cannot write offline journal for folder '%s': %s"),
+		journal->folder->full_name, g_strerror (errno));
 
 	fclose (fp);
 
@@ -197,7 +194,8 @@ camel_offline_journal_write (CamelOfflineJournal *journal, CamelException *ex)
  * Returns: %0 on success (no entry failed to replay) or %-1 on fail
  **/
 gint
-camel_offline_journal_replay (CamelOfflineJournal *journal, CamelException *ex)
+camel_offline_journal_replay (CamelOfflineJournal *journal,
+                              CamelException *ex)
 {
 	CamelDListNode *entry, *next;
 	CamelException lex;
diff --git a/camel/camel-offline-store.c b/camel/camel-offline-store.c
index 5cf2681..3e11bf1 100644
--- a/camel/camel-offline-store.c
+++ b/camel/camel-offline-store.c
@@ -24,7 +24,6 @@
 #include <config.h>
 #endif
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 
 #include "camel-folder.h"
@@ -32,68 +31,63 @@
 #include "camel-offline-store.h"
 #include "camel-session.h"
 
-static void camel_offline_store_class_init (CamelOfflineStoreClass *klass);
-static void camel_offline_store_init (CamelOfflineStore *store, CamelOfflineStoreClass *klass);
-static void camel_offline_store_finalize (CamelObject *object);
+static gpointer camel_offline_store_parent_class;
 
-static void offline_store_construct (CamelService *service, CamelSession *session,
-				     CamelProvider *provider, CamelURL *url,
-				     CamelException *ex);
-
-static CamelStoreClass *parent_class = NULL;
-
-CamelType
-camel_offline_store_get_type (void)
+static void
+offline_store_construct (CamelService *service,
+                         CamelSession *session,
+                         CamelProvider *provider,
+                         CamelURL *url,
+                         CamelException *ex)
 {
-	static CamelType type = NULL;
+	CamelOfflineStore *store = CAMEL_OFFLINE_STORE (service);
+	CamelServiceClass *service_class;
 
-	if (!type) {
-		type = camel_type_register (CAMEL_STORE_TYPE,
-					    "CamelOfflineStore",
-					    sizeof (CamelOfflineStore),
-					    sizeof (CamelOfflineStoreClass),
-					    (CamelObjectClassInitFunc) camel_offline_store_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_offline_store_init,
-					    (CamelObjectFinalizeFunc) camel_offline_store_finalize);
-	}
+	/* Chain up to parent's construct() method. */
+	service_class = CAMEL_SERVICE_CLASS (camel_offline_store_parent_class);
+	service_class->construct (service, session, provider, url, ex);
+	if (camel_exception_is_set (ex))
+		return;
 
-	return type;
+	store->state = camel_session_is_online (session) ?
+		CAMEL_OFFLINE_STORE_NETWORK_AVAIL :
+		CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL;
 }
 
 static void
-camel_offline_store_class_init (CamelOfflineStoreClass *klass)
+camel_offline_store_class_init (CamelOfflineStoreClass *class)
 {
-	parent_class = (CamelStoreClass *) camel_type_get_global_classfuncs (CAMEL_STORE_TYPE);
+	CamelServiceClass *service_class;
 
-	((CamelServiceClass *) klass)->construct = offline_store_construct;
-}
+	camel_offline_store_parent_class = (CamelStoreClass *) camel_type_get_global_classfuncs (CAMEL_STORE_TYPE);
 
-static void
-camel_offline_store_init (CamelOfflineStore *store, CamelOfflineStoreClass *klass)
-{
-	store->state = CAMEL_OFFLINE_STORE_NETWORK_AVAIL;
+	service_class = CAMEL_SERVICE_CLASS (class);
+	service_class->construct = offline_store_construct;
 }
 
 static void
-camel_offline_store_finalize (CamelObject *object)
+camel_offline_store_init (CamelOfflineStore *store)
 {
-	;
+	store->state = CAMEL_OFFLINE_STORE_NETWORK_AVAIL;
 }
 
-static void
-offline_store_construct (CamelService *service, CamelSession *session,
-			  CamelProvider *provider, CamelURL *url,
-			  CamelException *ex)
+CamelType
+camel_offline_store_get_type (void)
 {
-	CamelOfflineStore *store = CAMEL_OFFLINE_STORE (service);
+	static CamelType type = NULL;
 
-	CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
-	if (camel_exception_is_set (ex))
-		return;
+	if (!type) {
+		type = camel_type_register (CAMEL_STORE_TYPE,
+					    "CamelOfflineStore",
+					    sizeof (CamelOfflineStore),
+					    sizeof (CamelOfflineStoreClass),
+					    (CamelObjectClassInitFunc) camel_offline_store_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_offline_store_init,
+					    (CamelObjectFinalizeFunc) NULL);
+	}
 
-	store->state = camel_session_is_online (session) ?
-		CAMEL_OFFLINE_STORE_NETWORK_AVAIL : CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL;
+	return type;
 }
 
 /**
@@ -107,7 +101,8 @@ offline_store_construct (CamelService *service, CamelSession *session,
  * Since: 2.24
  **/
 gint
-camel_offline_store_get_network_state (CamelOfflineStore *store, CamelException *ex)
+camel_offline_store_get_network_state (CamelOfflineStore *store,
+                                       CamelException *ex)
 {
 	return store->state;
 }
@@ -122,7 +117,9 @@ camel_offline_store_get_network_state (CamelOfflineStore *store, CamelException
  * or #CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL.
  **/
 void
-camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, CamelException *ex)
+camel_offline_store_set_network_state (CamelOfflineStore *store,
+                                       gint state,
+                                       CamelException *ex)
 {
 	CamelException lex;
 	CamelService *service = CAMEL_SERVICE (store);
@@ -182,7 +179,8 @@ camel_offline_store_set_network_state (CamelOfflineStore *store, gint state, Cam
  * Since: 2.22
  **/
 void
-camel_offline_store_prepare_for_offline (CamelOfflineStore *store, CamelException *ex)
+camel_offline_store_prepare_for_offline (CamelOfflineStore *store,
+                                         CamelException *ex)
 {
 	CamelException lex;
 	CamelService *service = CAMEL_SERVICE (store);
diff --git a/camel/camel-partition-table.c b/camel/camel-partition-table.c
index a88ae09..9ea4bf3 100644
--- a/camel/camel-partition-table.c
+++ b/camel/camel-partition-table.c
@@ -81,7 +81,7 @@ camel_partition_table_finalize(CamelPartitionTable *cpi)
 		}
 		camel_block_file_sync(cpi->blocks);
 
-		camel_object_unref((CamelObject *)cpi->blocks);
+		camel_object_unref (cpi->blocks);
 	}
 
 	pthread_mutex_destroy(&p->lock);
@@ -195,8 +195,7 @@ CamelPartitionTable *camel_partition_table_new(struct _CamelBlockFile *bs, camel
 
 	cpi = (CamelPartitionTable *)camel_object_new(camel_partition_table_get_type());
 	cpi->rootid = root;
-	cpi->blocks = bs;
-	camel_object_ref((CamelObject *)bs);
+	cpi->blocks = camel_object_ref (bs);
 
 	/* read the partition table into memory */
 	do {
@@ -236,7 +235,7 @@ CamelPartitionTable *camel_partition_table_new(struct _CamelBlockFile *bs, camel
 	return cpi;
 
 fail:
-	camel_object_unref((CamelObject *)cpi);
+	camel_object_unref (cpi);
 	return NULL;
 }
 
@@ -616,7 +615,7 @@ camel_key_table_finalize(CamelKeyTable *ki)
 			camel_block_file_unref_block(ki->blocks, ki->root_block);
 		}
 		camel_block_file_sync(ki->blocks);
-		camel_object_unref((CamelObject *)ki->blocks);
+		camel_object_unref (ki->blocks);
 	}
 
 	pthread_mutex_destroy(&p->lock);
@@ -650,13 +649,12 @@ camel_key_table_new(CamelBlockFile *bs, camel_block_t root)
 
 	ki = (CamelKeyTable *)camel_object_new(camel_key_table_get_type());
 
-	ki->blocks = bs;
-	camel_object_ref((CamelObject *)bs);
+	ki->blocks = camel_object_ref (bs);
 	ki->rootid = root;
 
 	ki->root_block = camel_block_file_get_block(bs, ki->rootid);
 	if (ki->root_block == NULL) {
-		camel_object_unref((CamelObject *)ki);
+		camel_object_unref (ki);
 		ki = NULL;
 	} else {
 		camel_block_file_detach_block(bs, ki->root_block);
diff --git a/camel/camel-sasl.c b/camel/camel-sasl.c
index 5fa7861..467d701 100644
--- a/camel/camel-sasl.c
+++ b/camel/camel-sasl.c
@@ -65,8 +65,7 @@ sasl_set_service (CamelSasl *sasl,
 	g_return_if_fail (CAMEL_IS_SERVICE (service));
 	g_return_if_fail (sasl->priv->service == NULL);
 
-	sasl->priv->service = service;
-	camel_object_ref (service);
+	sasl->priv->service = camel_object_ref (service);
 }
 
 static void
diff --git a/camel/camel-seekable-substream.c b/camel/camel-seekable-substream.c
index 43e0dd6..e7733f6 100644
--- a/camel/camel-seekable-substream.c
+++ b/camel/camel-seekable-substream.c
@@ -288,8 +288,7 @@ camel_seekable_substream_new(CamelSeekableStream *parent_stream, off_t start, of
 	seekable_substream = CAMEL_SEEKABLE_SUBSTREAM (camel_object_new (camel_seekable_substream_get_type ()));
 
 	/* Initialize it. */
-	seekable_substream->parent_stream = parent_stream;
-	camel_object_ref (parent_stream);
+	seekable_substream->parent_stream = camel_object_ref (parent_stream);
 
 	/* Set the bound of the substream. We can ignore any possible error
 	 * here, because if we fail to seek now, it will try again later. */
diff --git a/camel/camel-service.c b/camel/camel-service.c
index dcd39fa..6b620f5 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -218,8 +218,7 @@ service_construct (CamelService *service,
 
 	service->provider = provider;
 	service->url = camel_url_copy(url);
-	service->session = session;
-	camel_object_ref (session);
+	service->session = camel_object_ref (session);
 
 	service->status = CAMEL_SERVICE_DISCONNECTED;
 
diff --git a/camel/camel-session.c b/camel/camel-session.c
index dd74fc1..0644466 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -189,8 +189,7 @@ session_thread_msg_new (CamelSession *session,
 
 	m = g_malloc0(size);
 	m->ops = ops;
-	m->session = session;
-	camel_object_ref (session);
+	m->session = camel_object_ref (session);
 	m->op = camel_operation_new(cs_thread_status, m);
 	camel_exception_init(&m->ex);
 	CAMEL_SESSION_LOCK(session, thread_lock);
diff --git a/camel/camel-smime-context.c b/camel/camel-smime-context.c
index d663940..68a53e6 100644
--- a/camel/camel-smime-context.c
+++ b/camel/camel-smime-context.c
@@ -1059,7 +1059,7 @@ smime_context_encrypt (CamelCipherContext *context,
 		set_nss_error (ex, _("Failed to add data to encoder"));
 		goto fail;
 	}
-	camel_object_unref(mem);
+	camel_object_unref (mem);
 
 	if (NSS_CMSEncoder_Finish(enc) != SECSuccess) {
 		set_nss_error (ex, _("Failed to encode data"));
diff --git a/camel/camel-store-summary.c b/camel/camel-store-summary.c
index 37eeed9..746ba6c 100644
--- a/camel/camel-store-summary.c
+++ b/camel/camel-store-summary.c
@@ -54,16 +54,16 @@
 
 #define _PRIVATE(o) (((CamelStoreSummary *)(o))->priv)
 
-static gint summary_header_load(CamelStoreSummary *, FILE *);
-static gint summary_header_save(CamelStoreSummary *, FILE *);
+static gint summary_header_load (CamelStoreSummary *, FILE *);
+static gint summary_header_save (CamelStoreSummary *, FILE *);
 
-static CamelStoreInfo * store_info_new(CamelStoreSummary *, const gchar *);
-static CamelStoreInfo * store_info_load(CamelStoreSummary *, FILE *);
-static gint		 store_info_save(CamelStoreSummary *, FILE *, CamelStoreInfo *);
-static void		 store_info_free(CamelStoreSummary *, CamelStoreInfo *);
+static CamelStoreInfo * store_info_new (CamelStoreSummary *, const gchar *);
+static CamelStoreInfo * store_info_load (CamelStoreSummary *, FILE *);
+static gint		 store_info_save (CamelStoreSummary *, FILE *, CamelStoreInfo *);
+static void		 store_info_free (CamelStoreSummary *, CamelStoreInfo *);
 
-static const gchar *store_info_string(CamelStoreSummary *, const CamelStoreInfo *, gint);
-static void store_info_set_string(CamelStoreSummary *, CamelStoreInfo *, int, const gchar *);
+static const gchar *store_info_string (CamelStoreSummary *, const CamelStoreInfo *, gint);
+static void store_info_set_string (CamelStoreSummary *, CamelStoreInfo *, int, const gchar *);
 
 static void camel_store_summary_class_init (CamelStoreSummaryClass *klass);
 static void camel_store_summary_init       (CamelStoreSummary *obj);
@@ -93,9 +93,9 @@ camel_store_summary_init (CamelStoreSummary *s)
 {
 	struct _CamelStoreSummaryPrivate *p;
 
-	p = _PRIVATE(s) = g_malloc0(sizeof(*p));
+	p = _PRIVATE (s) = g_malloc0 (sizeof (*p));
 
-	s->store_info_size = sizeof(CamelStoreInfo);
+	s->store_info_size = sizeof (CamelStoreInfo);
 
 	s->store_info_chunks = NULL;
 
@@ -104,13 +104,13 @@ camel_store_summary_init (CamelStoreSummary *s)
 	s->count = 0;
 	s->time = 0;
 
-	s->folders = g_ptr_array_new();
-	s->folders_path = g_hash_table_new(g_str_hash, g_str_equal);
+	s->folders = g_ptr_array_new ();
+	s->folders_path = g_hash_table_new (g_str_hash, g_str_equal);
 
-	p->summary_lock = g_mutex_new();
-	p->io_lock = g_mutex_new();
-	p->alloc_lock = g_mutex_new();
-	p->ref_lock = g_mutex_new();
+	p->summary_lock = g_mutex_new ();
+	p->io_lock = g_mutex_new ();
+	p->alloc_lock = g_mutex_new ();
+	p->ref_lock = g_mutex_new ();
 }
 
 static void
@@ -119,23 +119,23 @@ camel_store_summary_finalize (CamelObject *obj)
 	struct _CamelStoreSummaryPrivate *p;
 	CamelStoreSummary *s = (CamelStoreSummary *)obj;
 
-	p = _PRIVATE(obj);
+	p = _PRIVATE (obj);
 
-	camel_store_summary_clear(s);
-	g_ptr_array_free(s->folders, TRUE);
-	g_hash_table_destroy(s->folders_path);
+	camel_store_summary_clear (s);
+	g_ptr_array_free (s->folders, TRUE);
+	g_hash_table_destroy (s->folders_path);
 
-	g_free(s->summary_path);
+	g_free (s->summary_path);
 
 	if (s->store_info_chunks)
-		e_memchunk_destroy(s->store_info_chunks);
+		e_memchunk_destroy (s->store_info_chunks);
 
-	g_mutex_free(p->summary_lock);
-	g_mutex_free(p->io_lock);
-	g_mutex_free(p->alloc_lock);
-	g_mutex_free(p->ref_lock);
+	g_mutex_free (p->summary_lock);
+	g_mutex_free (p->io_lock);
+	g_mutex_free (p->alloc_lock);
+	g_mutex_free (p->ref_lock);
 
-	g_free(p);
+	g_free (p);
 }
 
 CamelType
@@ -177,14 +177,14 @@ camel_store_summary_new (void)
  * Set the filename where the summary will be loaded to/saved from.
  **/
 void
-camel_store_summary_set_filename(CamelStoreSummary *s, const gchar *name)
+camel_store_summary_set_filename (CamelStoreSummary *s, const gchar *name)
 {
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
 
-	g_free(s->summary_path);
-	s->summary_path = g_strdup(name);
+	g_free (s->summary_path);
+	s->summary_path = g_strdup (name);
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 }
 
 /**
@@ -195,15 +195,15 @@ camel_store_summary_set_filename(CamelStoreSummary *s, const gchar *name)
  * Sets the base URI for the summary.
  **/
 void
-camel_store_summary_set_uri_base(CamelStoreSummary *s, CamelURL *base)
+camel_store_summary_set_uri_base (CamelStoreSummary *s, CamelURL *base)
 {
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
 
 	if (s->uri_base)
-		camel_url_free(s->uri_base);
-	s->uri_base = camel_url_new_with_base(base, "");
+		camel_url_free (s->uri_base);
+	s->uri_base = camel_url_new_with_base (base, "");
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 }
 
 /**
@@ -215,7 +215,7 @@ camel_store_summary_set_uri_base(CamelStoreSummary *s, CamelURL *base)
  * Returns: the number of items gint he summary.
  **/
 gint
-camel_store_summary_count(CamelStoreSummary *s)
+camel_store_summary_count (CamelStoreSummary *s)
 {
 	return s->folders->len;
 }
@@ -235,22 +235,22 @@ camel_store_summary_count(CamelStoreSummary *s)
  * Returns: the summary item, or %NULL if @index is out of range
  **/
 CamelStoreInfo *
-camel_store_summary_index(CamelStoreSummary *s, gint i)
+camel_store_summary_index (CamelStoreSummary *s, gint i)
 {
 	CamelStoreInfo *info = NULL;
 
-	CAMEL_STORE_SUMMARY_LOCK(s, ref_lock);
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
 
 	if (i<s->folders->len)
-		info = g_ptr_array_index(s->folders, i);
+		info = g_ptr_array_index (s->folders, i);
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 
 	if (info)
 		info->refcount++;
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
 
 	return info;
 }
@@ -267,23 +267,23 @@ camel_store_summary_index(CamelStoreSummary *s, gint i)
  * Returns: the summary array
  **/
 GPtrArray *
-camel_store_summary_array(CamelStoreSummary *s)
+camel_store_summary_array (CamelStoreSummary *s)
 {
 	CamelStoreInfo *info;
-	GPtrArray *res = g_ptr_array_new();
+	GPtrArray *res = g_ptr_array_new ();
 	gint i;
 
-	CAMEL_STORE_SUMMARY_LOCK(s, ref_lock);
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
 
-	g_ptr_array_set_size(res, s->folders->len);
+	g_ptr_array_set_size (res, s->folders->len);
 	for (i=0;i<s->folders->len;i++) {
-		info = res->pdata[i] = g_ptr_array_index(s->folders, i);
+		info = res->pdata[i] = g_ptr_array_index (s->folders, i);
 		info->refcount++;
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
-	CAMEL_STORE_SUMMARY_UNLOCK(s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
 
 	return res;
 }
@@ -296,14 +296,14 @@ camel_store_summary_array(CamelStoreSummary *s)
  * Free the folder summary array.
  **/
 void
-camel_store_summary_array_free(CamelStoreSummary *s, GPtrArray *array)
+camel_store_summary_array_free (CamelStoreSummary *s, GPtrArray *array)
 {
 	gint i;
 
 	for (i=0;i<array->len;i++)
-		camel_store_summary_info_free(s, array->pdata[i]);
+		camel_store_summary_info_free (s, array->pdata[i]);
 
-	g_ptr_array_free(array, TRUE);
+	g_ptr_array_free (array, TRUE);
 }
 
 /**
@@ -322,21 +322,21 @@ camel_store_summary_array_free(CamelStoreSummary *s, GPtrArray *array)
  * available
  **/
 CamelStoreInfo *
-camel_store_summary_path(CamelStoreSummary *s, const gchar *path)
+camel_store_summary_path (CamelStoreSummary *s, const gchar *path)
 {
 	CamelStoreInfo *info;
 
-	CAMEL_STORE_SUMMARY_LOCK(s, ref_lock);
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
 
-	info = g_hash_table_lookup(s->folders_path, path);
+	info = g_hash_table_lookup (s->folders_path, path);
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 
 	if (info)
 		info->refcount++;
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
 
 	return info;
 }
@@ -350,33 +350,33 @@ camel_store_summary_path(CamelStoreSummary *s, const gchar *path)
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_store_summary_load(CamelStoreSummary *s)
+camel_store_summary_load (CamelStoreSummary *s)
 {
 	FILE *in;
 	gint i;
 	CamelStoreInfo *info;
 
-	g_assert(s->summary_path);
+	g_assert (s->summary_path);
 
-	in = g_fopen(s->summary_path, "rb");
+	in = g_fopen (s->summary_path, "rb");
 	if (in == NULL)
 		return -1;
 
-	CAMEL_STORE_SUMMARY_LOCK(s, io_lock);
-	if ( ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in) == -1)
+	CAMEL_STORE_SUMMARY_LOCK (s, io_lock);
+	if ( ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->summary_header_load (s, in) == -1)
 		goto error;
 
 	/* now read in each message ... */
 	for (i=0;i<s->count;i++) {
-		info = ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_load(s, in);
+		info = ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->store_info_load (s, in);
 
 		if (info == NULL)
 			goto error;
 
-		camel_store_summary_add(s, info);
+		camel_store_summary_add (s, info);
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
 
 	if (fclose (in) != 0)
 		return -1;
@@ -388,7 +388,7 @@ camel_store_summary_load(CamelStoreSummary *s)
 error:
 	i = ferror (in);
 	g_warning ("Cannot load summary file: %s", g_strerror (ferror (in)));
-	CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
 	fclose (in);
 	s->flags |= ~CAMEL_STORE_SUMMARY_DIRTY;
 	errno = i;
@@ -406,7 +406,7 @@ error:
  * Returns: %0 on succes or %-1 on fail
  **/
 gint
-camel_store_summary_save(CamelStoreSummary *s)
+camel_store_summary_save (CamelStoreSummary *s)
 {
 	FILE *out;
 	gint fd;
@@ -414,38 +414,38 @@ camel_store_summary_save(CamelStoreSummary *s)
 	guint32 count;
 	CamelStoreInfo *info;
 
-	g_assert(s->summary_path);
+	g_assert (s->summary_path);
 
-	io(printf("** saving summary\n"));
+	io (printf ("** saving summary\n"));
 
 	if ((s->flags & CAMEL_STORE_SUMMARY_DIRTY) == 0) {
-		io(printf("**  summary clean no save\n"));
+		io (printf ("**  summary clean no save\n"));
 		return 0;
 	}
 
-	fd = g_open(s->summary_path, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600);
+	fd = g_open (s->summary_path, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600);
 	if (fd == -1) {
-		io(printf("**  open error: %s\n", g_strerror (errno)));
+		io (printf ("**  open error: %s\n", g_strerror (errno)));
 		return -1;
 	}
 
-	out = fdopen(fd, "wb");
+	out = fdopen (fd, "wb");
 	if (out == NULL) {
 		i = errno;
-		printf("**  fdopen error: %s\n", g_strerror (errno));
-		close(fd);
+		printf ("**  fdopen error: %s\n", g_strerror (errno));
+		close (fd);
 		errno = i;
 		return -1;
 	}
 
-	io(printf("saving header\n"));
+	io (printf ("saving header\n"));
 
-	CAMEL_STORE_SUMMARY_LOCK(s, io_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, io_lock);
 
-	if ( ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_save(s, out) == -1) {
+	if ( ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->summary_header_save (s, out) == -1) {
 		i = errno;
-		fclose(out);
-		CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
+		fclose (out);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
 		errno = i;
 		return -1;
 	}
@@ -457,10 +457,10 @@ camel_store_summary_save(CamelStoreSummary *s)
 	count = s->folders->len;
 	for (i=0;i<count;i++) {
 		info = s->folders->pdata[i];
-		((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_save(s, out, info);
+		((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->store_info_save (s, out, info);
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
 
 	if (fflush (out) != 0 || fsync (fileno (out)) == -1) {
 		i = errno;
@@ -487,22 +487,22 @@ camel_store_summary_save(CamelStoreSummary *s)
  * Returns: %0 on success or %-1 on fail
  **/
 gint
-camel_store_summary_header_load(CamelStoreSummary *s)
+camel_store_summary_header_load (CamelStoreSummary *s)
 {
 	FILE *in;
 	gint ret;
 
-	g_assert(s->summary_path);
+	g_assert (s->summary_path);
 
-	in = g_fopen(s->summary_path, "rb");
+	in = g_fopen (s->summary_path, "rb");
 	if (in == NULL)
 		return -1;
 
-	CAMEL_STORE_SUMMARY_LOCK(s, io_lock);
-	ret = ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in);
-	CAMEL_STORE_SUMMARY_UNLOCK(s, io_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, io_lock);
+	ret = ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->summary_header_load (s, in);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, io_lock);
 
-	fclose(in);
+	fclose (in);
 	s->flags &= ~CAMEL_STORE_SUMMARY_DIRTY;
 	return ret;
 }
@@ -521,23 +521,23 @@ camel_store_summary_header_load(CamelStoreSummary *s)
  * class.  And MUST NOT be allocated directly using malloc.
  **/
 void
-camel_store_summary_add(CamelStoreSummary *s, CamelStoreInfo *info)
+camel_store_summary_add (CamelStoreSummary *s, CamelStoreInfo *info)
 {
 	if (info == NULL)
 		return;
 
-	if (camel_store_info_path(s, info) == NULL) {
-		g_warning("Trying to add a folder info with missing required path name\n");
+	if (camel_store_info_path (s, info) == NULL) {
+		g_warning ("Trying to add a folder info with missing required path name\n");
 		return;
 	}
 
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
 
-	g_ptr_array_add(s->folders, info);
-	g_hash_table_insert(s->folders_path, (gchar *)camel_store_info_path(s, info), info);
+	g_ptr_array_add (s->folders, info);
+	g_hash_table_insert (s->folders_path, (gchar *)camel_store_info_path (s, info), info);
 	s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 }
 
 /**
@@ -550,24 +550,24 @@ camel_store_summary_add(CamelStoreSummary *s, CamelStoreInfo *info)
  * Returns: the newly added record
  **/
 CamelStoreInfo *
-camel_store_summary_add_from_path(CamelStoreSummary *s, const gchar *path)
+camel_store_summary_add_from_path (CamelStoreSummary *s, const gchar *path)
 {
 	CamelStoreInfo *info;
 
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
 
-	info = g_hash_table_lookup(s->folders_path, path);
+	info = g_hash_table_lookup (s->folders_path, path);
 	if (info != NULL) {
-		g_warning("Trying to add folder '%s' to summary that already has it", path);
+		g_warning ("Trying to add folder '%s' to summary that already has it", path);
 		info = NULL;
 	} else {
-		info = camel_store_summary_info_new_from_path(s, path);
-		g_ptr_array_add(s->folders, info);
-		g_hash_table_insert(s->folders_path, (gchar *)camel_store_info_path(s, info), info);
+		info = camel_store_summary_info_new_from_path (s, path);
+		g_ptr_array_add (s->folders, info);
+		g_hash_table_insert (s->folders_path, (gchar *)camel_store_info_path (s, info), info);
 		s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 
 	return info;
 }
@@ -586,9 +586,9 @@ camel_store_summary_add_from_path(CamelStoreSummary *s, const gchar *path)
  * Returns: the #CamelStoreInfo associated with @path
  **/
 CamelStoreInfo *
-camel_store_summary_info_new_from_path(CamelStoreSummary *s, const gchar *path)
+camel_store_summary_info_new_from_path (CamelStoreSummary *s, const gchar *path)
 {
-	return ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_new(s, path);
+	return ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->store_info_new (s, path);
 }
 
 /**
@@ -599,24 +599,24 @@ camel_store_summary_info_new_from_path(CamelStoreSummary *s, const gchar *path)
  * Unref and potentially free @info, and all associated memory.
  **/
 void
-camel_store_summary_info_free(CamelStoreSummary *s, CamelStoreInfo *info)
+camel_store_summary_info_free (CamelStoreSummary *s, CamelStoreInfo *info)
 {
-	g_assert(info);
-	g_assert(s);
+	g_assert (info);
+	g_assert (s);
 
-	CAMEL_STORE_SUMMARY_LOCK(s, ref_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
 
-	g_assert(info->refcount >= 1);
+	g_assert (info->refcount >= 1);
 
 	info->refcount--;
 	if (info->refcount > 0) {
-		CAMEL_STORE_SUMMARY_UNLOCK(s, ref_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
 		return;
 	}
 
-	CAMEL_STORE_SUMMARY_UNLOCK(s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
 
-	((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_free(s, info);
+	((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->store_info_free (s, info);
 }
 
 /**
@@ -627,15 +627,15 @@ camel_store_summary_info_free(CamelStoreSummary *s, CamelStoreInfo *info)
  * Add an extra reference to @info.
  **/
 void
-camel_store_summary_info_ref(CamelStoreSummary *s, CamelStoreInfo *info)
+camel_store_summary_info_ref (CamelStoreSummary *s, CamelStoreInfo *info)
 {
-	g_assert(info);
-	g_assert(s);
+	g_assert (info);
+	g_assert (s);
 
-	CAMEL_STORE_SUMMARY_LOCK(s, ref_lock);
-	g_assert(info->refcount >= 1);
+	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
+	g_assert (info->refcount >= 1);
 	info->refcount++;
-	CAMEL_STORE_SUMMARY_UNLOCK(s, ref_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
 }
 
 /**
@@ -646,11 +646,11 @@ camel_store_summary_info_ref(CamelStoreSummary *s, CamelStoreInfo *info)
  * written back to disk.
  **/
 void
-camel_store_summary_touch(CamelStoreSummary *s)
+camel_store_summary_touch (CamelStoreSummary *s)
 {
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
 	s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 }
 
 /**
@@ -660,24 +660,24 @@ camel_store_summary_touch(CamelStoreSummary *s)
  * Empty the summary contents.
  **/
 void
-camel_store_summary_clear(CamelStoreSummary *s)
+camel_store_summary_clear (CamelStoreSummary *s)
 {
 	gint i;
 
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
-	if (camel_store_summary_count(s) == 0) {
-		CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+	if (camel_store_summary_count (s) == 0) {
+		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 		return;
 	}
 
 	for (i=0;i<s->folders->len;i++)
-		camel_store_summary_info_free(s, s->folders->pdata[i]);
+		camel_store_summary_info_free (s, s->folders->pdata[i]);
 
-	g_ptr_array_set_size(s->folders, 0);
-	g_hash_table_destroy(s->folders_path);
-	s->folders_path = g_hash_table_new(g_str_hash, g_str_equal);
+	g_ptr_array_set_size (s->folders, 0);
+	g_hash_table_destroy (s->folders_path);
+	s->folders_path = g_hash_table_new (g_str_hash, g_str_equal);
 	s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 }
 
 /**
@@ -688,15 +688,15 @@ camel_store_summary_clear(CamelStoreSummary *s)
  * Remove a specific @info record from the summary.
  **/
 void
-camel_store_summary_remove(CamelStoreSummary *s, CamelStoreInfo *info)
+camel_store_summary_remove (CamelStoreSummary *s, CamelStoreInfo *info)
 {
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
-	g_hash_table_remove(s->folders_path, camel_store_info_path(s, info));
-	g_ptr_array_remove(s->folders, info);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+	g_hash_table_remove (s->folders_path, camel_store_info_path (s, info));
+	g_ptr_array_remove (s->folders, info);
 	s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
-	CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 
-	camel_store_summary_info_free(s, info);
+	camel_store_summary_info_free (s, info);
 }
 
 /**
@@ -707,23 +707,23 @@ camel_store_summary_remove(CamelStoreSummary *s, CamelStoreInfo *info)
  * Remove a specific info record from the summary, by @path.
  **/
 void
-camel_store_summary_remove_path(CamelStoreSummary *s, const gchar *path)
+camel_store_summary_remove_path (CamelStoreSummary *s, const gchar *path)
 {
         CamelStoreInfo *oldinfo;
         gchar *oldpath;
 
-	CAMEL_STORE_SUMMARY_LOCK(s, ref_lock);
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
-        if (g_hash_table_lookup_extended(s->folders_path, path, (gpointer)&oldpath, (gpointer)&oldinfo)) {
+	CAMEL_STORE_SUMMARY_LOCK (s, ref_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+        if (g_hash_table_lookup_extended (s->folders_path, path, (gpointer)&oldpath, (gpointer)&oldinfo)) {
 		/* make sure it doesn't vanish while we're removing it */
 		oldinfo->refcount++;
-		CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
-		CAMEL_STORE_SUMMARY_UNLOCK(s, ref_lock);
-		camel_store_summary_remove(s, oldinfo);
-		camel_store_summary_info_free(s, oldinfo);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
+		camel_store_summary_remove (s, oldinfo);
+		camel_store_summary_info_free (s, oldinfo);
         } else {
-		CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
-		CAMEL_STORE_SUMMARY_UNLOCK(s, ref_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, ref_lock);
 	}
 }
 
@@ -735,37 +735,37 @@ camel_store_summary_remove_path(CamelStoreSummary *s, const gchar *path)
  * Remove a specific info record from the summary, by index.
  **/
 void
-camel_store_summary_remove_index(CamelStoreSummary *s, gint index)
+camel_store_summary_remove_index (CamelStoreSummary *s, gint index)
 {
-	CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
+	CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
 	if (index < s->folders->len) {
 		CamelStoreInfo *info = s->folders->pdata[index];
 
-		g_hash_table_remove(s->folders_path, camel_store_info_path(s, info));
-		g_ptr_array_remove_index(s->folders, index);
+		g_hash_table_remove (s->folders_path, camel_store_info_path (s, info));
+		g_ptr_array_remove_index (s->folders, index);
 		s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
 
-		CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
-		camel_store_summary_info_free(s, info);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
+		camel_store_summary_info_free (s, info);
 	} else {
-		CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 	}
 }
 
 static gint
-summary_header_load(CamelStoreSummary *s, FILE *in)
+summary_header_load (CamelStoreSummary *s, FILE *in)
 {
 	gint32 version, flags, count;
 	time_t time;
 
-	fseek(in, 0, SEEK_SET);
+	fseek (in, 0, SEEK_SET);
 
-	io(printf("Loading header\n"));
+	io (printf ("Loading header\n"));
 
-	if (camel_file_util_decode_fixed_int32(in, &version) == -1
-	    || camel_file_util_decode_fixed_int32(in, &flags) == -1
-	    || camel_file_util_decode_time_t(in, &time) == -1
-	    || camel_file_util_decode_fixed_int32(in, &count) == -1) {
+	if (camel_file_util_decode_fixed_int32 (in, &version) == -1
+	    || camel_file_util_decode_fixed_int32 (in, &flags) == -1
+	    || camel_file_util_decode_time_t (in, &time) == -1
+	    || camel_file_util_decode_fixed_int32 (in, &count) == -1) {
 		return -1;
 	}
 
@@ -775,7 +775,7 @@ summary_header_load(CamelStoreSummary *s, FILE *in)
 	s->version = version;
 
 	if (version < CAMEL_STORE_SUMMARY_VERSION_0) {
-		g_warning("Store summary header version too low");
+		g_warning ("Store summary header version too low");
 		return -1;
 	}
 
@@ -783,17 +783,17 @@ summary_header_load(CamelStoreSummary *s, FILE *in)
 }
 
 static gint
-summary_header_save(CamelStoreSummary *s, FILE *out)
+summary_header_save (CamelStoreSummary *s, FILE *out)
 {
-	fseek(out, 0, SEEK_SET);
+	fseek (out, 0, SEEK_SET);
 
-	io(printf("Savining header\n"));
+	io (printf ("Savining header\n"));
 
 	/* always write latest version */
-	camel_file_util_encode_fixed_int32(out, CAMEL_STORE_SUMMARY_VERSION);
-	camel_file_util_encode_fixed_int32(out, s->flags);
-	camel_file_util_encode_time_t(out, s->time);
-	return camel_file_util_encode_fixed_int32(out, camel_store_summary_count(s));
+	camel_file_util_encode_fixed_int32 (out, CAMEL_STORE_SUMMARY_VERSION);
+	camel_file_util_encode_fixed_int32 (out, s->flags);
+	camel_file_util_encode_time_t (out, s->time);
+	return camel_file_util_encode_fixed_int32 (out, camel_store_summary_count (s));
 }
 
 /**
@@ -806,11 +806,11 @@ summary_header_save(CamelStoreSummary *s, FILE *out)
  * Returns: the newly allocated #CamelStoreInfo
  **/
 CamelStoreInfo *
-camel_store_summary_info_new(CamelStoreSummary *s)
+camel_store_summary_info_new (CamelStoreSummary *s)
 {
 	CamelStoreInfo *info;
 
-	info = g_slice_alloc0(s->store_info_size);
+	info = g_slice_alloc0 (s->store_info_size);
 	info->refcount = 1;
 	return info;
 }
@@ -826,9 +826,9 @@ camel_store_summary_info_new(CamelStoreSummary *s)
  * Returns: the string value
  **/
 const gchar *
-camel_store_info_string(CamelStoreSummary *s, const CamelStoreInfo *info, gint type)
+camel_store_info_string (CamelStoreSummary *s, const CamelStoreInfo *info, gint type)
 {
-	return ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_string(s, info, type);
+	return ((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->store_info_string (s, info, type);
 }
 
 /**
@@ -841,19 +841,19 @@ camel_store_info_string(CamelStoreSummary *s, const CamelStoreInfo *info, gint t
  * Set a specific string on the @info.
  **/
 void
-camel_store_info_set_string(CamelStoreSummary *s, CamelStoreInfo *info, gint type, const gchar *value)
+camel_store_info_set_string (CamelStoreSummary *s, CamelStoreInfo *info, gint type, const gchar *value)
 {
-	((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->store_info_set_string(s, info, type, value);
+	((CamelStoreSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->store_info_set_string (s, info, type, value);
 }
 
 static CamelStoreInfo *
-store_info_new(CamelStoreSummary *s, const gchar *f)
+store_info_new (CamelStoreSummary *s, const gchar *f)
 {
 	CamelStoreInfo *info;
 
-	info = camel_store_summary_info_new(s);
+	info = camel_store_summary_info_new (s);
 
-	info->path = g_strdup(f);
+	info->path = g_strdup (f);
 	info->unread = CAMEL_STORE_INFO_FOLDER_UNKNOWN;
 	info->total = CAMEL_STORE_INFO_FOLDER_UNKNOWN;
 
@@ -861,18 +861,18 @@ store_info_new(CamelStoreSummary *s, const gchar *f)
 }
 
 static CamelStoreInfo *
-store_info_load(CamelStoreSummary *s, FILE *in)
+store_info_load (CamelStoreSummary *s, FILE *in)
 {
 	CamelStoreInfo *info;
 
-	info = camel_store_summary_info_new(s);
+	info = camel_store_summary_info_new (s);
 
-	io(printf("Loading folder info\n"));
+	io (printf ("Loading folder info\n"));
 
-	camel_file_util_decode_string(in, &info->path);
-	camel_file_util_decode_uint32(in, &info->flags);
-	camel_file_util_decode_uint32(in, &info->unread);
-	camel_file_util_decode_uint32(in, &info->total);
+	camel_file_util_decode_string (in, &info->path);
+	camel_file_util_decode_uint32 (in, &info->flags);
+	camel_file_util_decode_uint32 (in, &info->unread);
+	camel_file_util_decode_uint32 (in, &info->total);
 
 	/* Ok, brown paper bag bug - prior to version 2 of the file, flags are
 	   stored using the bit number, not the bit. Try to recover as best we can */
@@ -891,37 +891,37 @@ store_info_load(CamelStoreSummary *s, FILE *in)
 		info->flags = flags;
 	}
 
-	if (!ferror(in))
+	if (!ferror (in))
 		return info;
 
-	camel_store_summary_info_free(s, info);
+	camel_store_summary_info_free (s, info);
 
 	return NULL;
 }
 
 static gint
-store_info_save(CamelStoreSummary *s, FILE *out, CamelStoreInfo *info)
+store_info_save (CamelStoreSummary *s, FILE *out, CamelStoreInfo *info)
 {
-	io(printf("Saving folder info\n"));
+	io (printf ("Saving folder info\n"));
 
-	camel_file_util_encode_string(out, camel_store_info_path(s, info));
-	camel_file_util_encode_uint32(out, info->flags);
-	camel_file_util_encode_uint32(out, info->unread);
-	camel_file_util_encode_uint32(out, info->total);
+	camel_file_util_encode_string (out, camel_store_info_path (s, info));
+	camel_file_util_encode_uint32 (out, info->flags);
+	camel_file_util_encode_uint32 (out, info->unread);
+	camel_file_util_encode_uint32 (out, info->total);
 
-	return ferror(out);
+	return ferror (out);
 }
 
 static void
-store_info_free(CamelStoreSummary *s, CamelStoreInfo *info)
+store_info_free (CamelStoreSummary *s, CamelStoreInfo *info)
 {
-	g_free(info->path);
-	g_free(info->uri);
-	g_slice_free1(s->store_info_size, info);
+	g_free (info->path);
+	g_free (info->uri);
+	g_slice_free1 (s->store_info_size, info);
 }
 
 static const gchar *
-store_info_string(CamelStoreSummary *s, const CamelStoreInfo *info, gint type)
+store_info_string (CamelStoreSummary *s, const CamelStoreInfo *info, gint type)
 {
 	const gchar *p;
 
@@ -933,7 +933,7 @@ store_info_string(CamelStoreSummary *s, const CamelStoreInfo *info, gint type)
 	case CAMEL_STORE_INFO_PATH:
 		return info->path;
 	case CAMEL_STORE_INFO_NAME:
-		p = strrchr(info->path, '/');
+		p = strrchr (info->path, '/');
 		if (p)
 			return p+1;
 		else
@@ -942,9 +942,9 @@ store_info_string(CamelStoreSummary *s, const CamelStoreInfo *info, gint type)
 		if (info->uri == NULL) {
 			CamelURL *uri;
 
-			uri = camel_url_new_with_base(s->uri_base, info->path);
-			((CamelStoreInfo *)info)->uri = camel_url_to_string(uri, 0);
-			camel_url_free(uri);
+			uri = camel_url_new_with_base (s->uri_base, info->path);
+			((CamelStoreInfo *)info)->uri = camel_url_to_string (uri, 0);
+			camel_url_free (uri);
 		}
 		return info->uri;
 	}
@@ -963,38 +963,38 @@ store_info_set_string (CamelStoreSummary *s, CamelStoreInfo *info, gint type, co
 
 	switch (type) {
 	case CAMEL_STORE_INFO_PATH:
-		CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
-		g_hash_table_remove(s->folders_path, (gchar *)camel_store_info_path(s, info));
-		g_free(info->path);
-		g_free(info->uri);
+		CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+		g_hash_table_remove (s->folders_path, (gchar *)camel_store_info_path (s, info));
+		g_free (info->path);
+		g_free (info->uri);
 		info->uri = NULL;
-		info->path = g_strdup(str);
-		g_hash_table_insert(s->folders_path, (gchar *)camel_store_info_path(s, info), info);
+		info->path = g_strdup (str);
+		g_hash_table_insert (s->folders_path, (gchar *)camel_store_info_path (s, info), info);
 		s->flags |= CAMEL_STORE_SUMMARY_DIRTY;
-		CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 		break;
 	case CAMEL_STORE_INFO_NAME:
-		CAMEL_STORE_SUMMARY_LOCK(s, summary_lock);
-		g_hash_table_remove(s->folders_path, (gchar *)camel_store_info_path(s, info));
-		p = strrchr(info->path, '/');
+		CAMEL_STORE_SUMMARY_LOCK (s, summary_lock);
+		g_hash_table_remove (s->folders_path, (gchar *)camel_store_info_path (s, info));
+		p = strrchr (info->path, '/');
 		if (p) {
 			len = p-info->path+1;
-			v = g_malloc(len+strlen(str)+1);
-			memcpy(v, info->path, len);
-			strcpy(v+len, str);
+			v = g_malloc (len+strlen (str)+1);
+			memcpy (v, info->path, len);
+			strcpy (v+len, str);
 		} else {
-			v = g_strdup(str);
+			v = g_strdup (str);
 		}
-		g_free(info->path);
+		g_free (info->path);
 		info->path = v;
 		g_free (info->uri);
 		info->uri = NULL;
-		g_hash_table_insert(s->folders_path, (gchar *)camel_store_info_path(s, info), info);
-		CAMEL_STORE_SUMMARY_UNLOCK(s, summary_lock);
+		g_hash_table_insert (s->folders_path, (gchar *)camel_store_info_path (s, info), info);
+		CAMEL_STORE_SUMMARY_UNLOCK (s, summary_lock);
 		break;
 	case CAMEL_STORE_INFO_URI:
-		g_warning("Cannot set store info uri, aborting");
-		abort();
+		g_warning ("Cannot set store info uri, aborting");
+		abort ();
 		break;
 	}
 }
diff --git a/camel/camel-store.c b/camel/camel-store.c
index e62fa99..4ca6c6a 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -349,13 +349,13 @@ camel_store_get_folder (CamelStore *store, const gchar *folder_name, guint32 fla
 				if ((store->flags & CAMEL_STORE_VTRASH)
 				    && (vfolder = camel_object_bag_get(store->folders, CAMEL_VTRASH_NAME))) {
 					camel_vee_folder_add_folder(vfolder, folder);
-					camel_object_unref(vfolder);
+					camel_object_unref (vfolder);
 				}
 
 				if ((store->flags & CAMEL_STORE_VJUNK)
 				    && (vfolder = camel_object_bag_get(store->folders, CAMEL_VJUNK_NAME))) {
 					camel_vee_folder_add_folder(vfolder, folder);
-					camel_object_unref(vfolder);
+					camel_object_unref (vfolder);
 				}
 			}
 		}
@@ -444,19 +444,19 @@ cs_delete_cached_folder(CamelStore *store, const gchar *folder_name)
 		if ((store->flags & CAMEL_STORE_VTRASH)
 		    && (vfolder = camel_object_bag_get(store->folders, CAMEL_VTRASH_NAME))) {
 			camel_vee_folder_remove_folder(vfolder, folder);
-			camel_object_unref(vfolder);
+			camel_object_unref (vfolder);
 		}
 
 		if ((store->flags & CAMEL_STORE_VJUNK)
 		    && (vfolder = camel_object_bag_get(store->folders, CAMEL_VJUNK_NAME))) {
 			camel_vee_folder_remove_folder(vfolder, folder);
-			camel_object_unref(vfolder);
+			camel_object_unref (vfolder);
 		}
 
 		camel_folder_delete(folder);
 
 		camel_object_bag_remove(store->folders, folder);
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 	}
 }
 
@@ -568,7 +568,7 @@ camel_store_rename_folder (CamelStore *store, const gchar *old_namein, const gch
 			} else {
 				g_ptr_array_remove_index_fast(folders, i);
 				i--;
-				camel_object_unref(folder);
+				camel_object_unref (folder);
 			}
 		}
 	}
@@ -593,7 +593,7 @@ camel_store_rename_folder (CamelStore *store, const gchar *old_namein, const gch
 				g_free(new);
 
 				CAMEL_FOLDER_REC_UNLOCK(folder, lock);
-				camel_object_unref(folder);
+				camel_object_unref (folder);
 			}
 
 			/* Emit renamed signal */
@@ -611,7 +611,7 @@ camel_store_rename_folder (CamelStore *store, const gchar *old_namein, const gch
 			for (i=0;i<folders->len;i++) {
 				folder = folders->pdata[i];
 				CAMEL_FOLDER_REC_UNLOCK(folder, lock);
-				camel_object_unref(folder);
+				camel_object_unref (folder);
 			}
 		}
 	}
@@ -663,7 +663,7 @@ get_special(CamelStore *store, camel_vtrash_folder_t type)
 	for (i=0;i<folders->len;i++) {
 		if (!CAMEL_IS_VTRASH_FOLDER(folders->pdata[i]))
 			camel_vee_folder_add_folder((CamelVeeFolder *)folder, (CamelFolder *)folders->pdata[i]);
-		camel_object_unref(folders->pdata[i]);
+		camel_object_unref (folders->pdata[i]);
 	}
 	g_ptr_array_free(folders, TRUE);
 
@@ -748,7 +748,7 @@ store_sync (CamelStore *store, gint expunge, CamelException *ex)
 				ignore_no_such_table_exception (&x);
 			} else if (CAMEL_IS_VEE_FOLDER(folder))
 				camel_vee_folder_sync_headers(folder, NULL); /* Literally don't care of vfolder exceptions */
-			camel_object_unref(folder);
+			camel_object_unref (folder);
 		}
 		camel_exception_xfer(ex, &x);
 		g_ptr_array_free(folders, TRUE);
diff --git a/camel/camel-stream-buffer.c b/camel/camel-stream-buffer.c
index 4bf8752..b68de66 100644
--- a/camel/camel-stream-buffer.c
+++ b/camel/camel-stream-buffer.c
@@ -285,8 +285,7 @@ stream_buffer_init_vbuf (CamelStreamBuffer *stream,
 	if (priv->stream)
 		camel_object_unref (priv->stream);
 
-	priv->stream = other_stream;
-	camel_object_ref (priv->stream);
+	priv->stream = camel_object_ref (other_stream);
 }
 
 static void
diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c
index 57a125a..2ea2d7c 100644
--- a/camel/camel-stream-filter.c
+++ b/camel/camel-stream-filter.c
@@ -357,8 +357,7 @@ camel_stream_filter_new (CamelStream *source)
 	stream = CAMEL_STREAM (camel_object_new (camel_stream_filter_get_type ()));
 	priv = CAMEL_STREAM_FILTER (stream)->priv;
 
-	priv->source = source;
-	camel_object_ref (source);
+	priv->source = camel_object_ref (source);
 
 	return stream;
 }
@@ -398,8 +397,7 @@ camel_stream_filter_add (CamelStreamFilter *stream,
 
 	fn = g_malloc(sizeof(*fn));
 	fn->id = priv->filterid++;
-	fn->filter = filter;
-	camel_object_ref (filter);
+	fn->filter = camel_object_ref (filter);
 
 	/* sure, we could use a GList, but we wouldn't save much */
 	f = (struct _filter *)&priv->filters;
diff --git a/camel/camel-tcp-stream-ssl.c b/camel/camel-tcp-stream-ssl.c
index 111408a..42d2f4e 100644
--- a/camel/camel-tcp-stream-ssl.c
+++ b/camel/camel-tcp-stream-ssl.c
@@ -1245,8 +1245,7 @@ camel_tcp_stream_ssl_new (CamelSession *session, const gchar *expected_host, gui
 
 	stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
 
-	stream->priv->session = session;
-	camel_object_ref (session);
+	stream->priv->session = camel_object_ref (session);
 	stream->priv->expected_host = g_strdup (expected_host);
 	stream->priv->ssl_mode = TRUE;
 	stream->priv->flags = flags;
@@ -1278,8 +1277,7 @@ camel_tcp_stream_ssl_new_raw (CamelSession *session, const gchar *expected_host,
 
 	stream = CAMEL_TCP_STREAM_SSL (camel_object_new (camel_tcp_stream_ssl_get_type ()));
 
-	stream->priv->session = session;
-	camel_object_ref (session);
+	stream->priv->session = camel_object_ref (session);
 	stream->priv->expected_host = g_strdup (expected_host);
 	stream->priv->ssl_mode = FALSE;
 	stream->priv->flags = flags;
diff --git a/camel/camel-text-index.c b/camel/camel-text-index.c
index b81a192..0d9c571 100644
--- a/camel/camel-text-index.c
+++ b/camel/camel-text-index.c
@@ -33,7 +33,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include <glib.h>
 #include <glib/gstdio.h>
 
 #include "camel-block-file.h"
@@ -46,7 +45,7 @@
 
 #define w(x)
 #define io(x)
-#define d(x) /*(printf("%s(%d):%s: ",  __FILE__, __LINE__, __PRETTY_FUNCTION__),(x))*/
+#define d(x) /*(printf ("%s (%d):%s: ",  __FILE__, __LINE__, __PRETTY_FUNCTION__),(x))*/
 
 /* cursor debug */
 #define c(x)
@@ -54,11 +53,11 @@
 #define CAMEL_TEXT_INDEX_MAX_WORDLEN  (36)
 
 #define CAMEL_TEXT_INDEX_LOCK(kf, lock) \
-	(g_static_rec_mutex_lock(&((CamelTextIndex *)kf)->priv->lock))
+	(g_static_rec_mutex_lock (&((CamelTextIndex *)kf)->priv->lock))
 #define CAMEL_TEXT_INDEX_UNLOCK(kf, lock) \
-	(g_static_rec_mutex_unlock(&((CamelTextIndex *)kf)->priv->lock))
+	(g_static_rec_mutex_unlock (&((CamelTextIndex *)kf)->priv->lock))
 
-static gint text_index_compress_nosync(CamelIndex *idx);
+static gint text_index_compress_nosync (CamelIndex *idx);
 
 /* ********************************************************************** */
 
@@ -68,7 +67,7 @@ struct _CamelTextIndexNamePrivate {
 	CamelMemPool *pool;
 };
 
-CamelTextIndexName *camel_text_index_name_new(CamelTextIndex *idx, const gchar *name, camel_key_t nameid);
+CamelTextIndexName *camel_text_index_name_new (CamelTextIndex *idx, const gchar *name, camel_key_t nameid);
 
 /* ****************************** */
 
@@ -84,7 +83,7 @@ struct _CamelTextIndexCursorPrivate {
 	gchar *current;
 };
 
-CamelTextIndexCursor *camel_text_index_cursor_new(CamelTextIndex *idx, camel_block_t data);
+CamelTextIndexCursor *camel_text_index_cursor_new (CamelTextIndex *idx, camel_block_t data);
 
 /* ****************************** */
 
@@ -97,7 +96,7 @@ struct _CamelTextIndexKeyCursorPrivate {
 	gchar *current;
 };
 
-CamelTextIndexKeyCursor *camel_text_index_key_cursor_new(CamelTextIndex *idx, CamelKeyTable *table);
+CamelTextIndexKeyCursor *camel_text_index_key_cursor_new (CamelTextIndex *idx, CamelKeyTable *table);
 
 /* ********************************************************************** */
 
@@ -150,7 +149,7 @@ struct _CamelTextIndexWord {
 	camel_key_t names[32];
 };
 
-#define CTI_PRIVATE(o) (((CamelTextIndex *)(o))->priv)
+#define CAMEL_TEXT_INDEX_GET_PRIVATE(o) (((CamelTextIndex *)(o))->priv)
 
 #define CI_CLASS(o) ((CamelTextIndexClass *)(((CamelObject *)o)->classfuncs))
 
@@ -162,34 +161,36 @@ static CamelObjectClass *camel_text_index_parent;
 
 /* call locked */
 static void
-text_index_add_name_to_word(CamelIndex *idx, const gchar *word, camel_key_t nameid)
+text_index_add_name_to_word (CamelIndex *idx,
+                             const gchar *word,
+                             camel_key_t nameid)
 {
 	struct _CamelTextIndexWord *w, *wp, *ww;
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	camel_key_t wordid;
 	camel_block_t data;
 	struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *)p->blocks->root;
 
-	w = g_hash_table_lookup(p->words, word);
+	w = g_hash_table_lookup (p->words, word);
 	if (w == NULL) {
-		wordid = camel_partition_table_lookup(p->word_hash, word);
+		wordid = camel_partition_table_lookup (p->word_hash, word);
 		if (wordid == 0) {
 			data = 0;
-			wordid = camel_key_table_add(p->word_index, word, 0, 0);
+			wordid = camel_key_table_add (p->word_index, word, 0, 0);
 			if (wordid == 0) {
 				g_warning ("Could not create key entry for word '%s': %s\n",
 					   word, g_strerror (errno));
 				return;
 			}
-			if (camel_partition_table_add(p->word_hash, word, wordid) == -1) {
+			if (camel_partition_table_add (p->word_hash, word, wordid) == -1) {
 				g_warning ("Could not create hash entry for word '%s': %s\n",
 					   word, g_strerror (errno));
 				return;
 			}
 			rb->words++;
-			camel_block_file_touch_block(p->blocks, p->blocks->root_block);
+			camel_block_file_touch_block (p->blocks, p->blocks->root_block);
 		} else {
-			data = camel_key_table_lookup(p->word_index, wordid, NULL, NULL);
+			data = camel_key_table_lookup (p->word_index, wordid, NULL, NULL);
 			if (data == 0) {
 				g_warning ("Could not find key entry for word '%s': %s\n",
 					   word, g_strerror (errno));
@@ -197,47 +198,49 @@ text_index_add_name_to_word(CamelIndex *idx, const gchar *word, camel_key_t name
 			}
 		}
 
-		w = g_malloc0(sizeof(*w));
-		w->word = g_strdup(word);
+		w = g_malloc0 (sizeof (*w));
+		w->word = g_strdup (word);
 		w->wordid = wordid;
 		w->used = 1;
 		w->data = data;
 
 		w->names[0] = nameid;
-		g_hash_table_insert(p->words, w->word, w);
-		camel_dlist_addhead(&p->word_cache, (CamelDListNode *)w);
+		g_hash_table_insert (p->words, w->word, w);
+		camel_dlist_addhead (&p->word_cache, (CamelDListNode *)w);
 		p->word_cache_count++;
 		ww = (struct _CamelTextIndexWord *)p->word_cache.tailpred;
 		wp = ww->prev;
 		while (wp && p->word_cache_count > p->word_cache_limit) {
-			io(printf("writing key file entry '%s' [%x]\n", ww->word, ww->data));
-			if (camel_key_file_write(p->links, &ww->data, ww->used, ww->names) != -1) {
-				io(printf("  new data [%x]\n", ww->data));
+			io (printf ("writing key file entry '%s' [%x]\n", ww->word, ww->data));
+			if (camel_key_file_write (p->links, &ww->data, ww->used, ww->names) != -1) {
+				io (printf ("  new data [%x]\n", ww->data));
 				rb->keys++;
-				camel_block_file_touch_block(p->blocks, p->blocks->root_block);
+				camel_block_file_touch_block (p->blocks, p->blocks->root_block);
 				/* if this call fails - we still point to the old data - not fatal */
-				camel_key_table_set_data(p->word_index, ww->wordid, ww->data);
-				camel_dlist_remove((CamelDListNode *)ww);
-				g_hash_table_remove(p->words, ww->word);
-				g_free(ww->word);
-				g_free(ww);
+				camel_key_table_set_data (
+					p->word_index, ww->wordid, ww->data);
+				camel_dlist_remove ((CamelDListNode *)ww);
+				g_hash_table_remove (p->words, ww->word);
+				g_free (ww->word);
+				g_free (ww);
 				p->word_cache_count--;
 			}
 			ww = wp;
 			wp = wp->prev;
 		}
 	} else {
-		camel_dlist_remove((CamelDListNode *)w);
-		camel_dlist_addhead(&p->word_cache, (CamelDListNode *)w);
+		camel_dlist_remove ((CamelDListNode *)w);
+		camel_dlist_addhead (&p->word_cache, (CamelDListNode *)w);
 		w->names[w->used] = nameid;
 		w->used++;
 		if (w->used == G_N_ELEMENTS (w->names)) {
-			io(printf("writing key file entry '%s' [%x]\n", w->word, w->data));
-			if (camel_key_file_write(p->links, &w->data, w->used, w->names) != -1) {
+			io (printf ("writing key file entry '%s' [%x]\n", w->word, w->data));
+			if (camel_key_file_write (p->links, &w->data, w->used, w->names) != -1) {
 				rb->keys++;
-				camel_block_file_touch_block(p->blocks, p->blocks->root_block);
+				camel_block_file_touch_block (p->blocks, p->blocks->root_block);
 				/* if this call fails - we still point to the old data - not fatal */
-				camel_key_table_set_data(p->word_index, w->wordid, w->data);
+				camel_key_table_set_data (
+					p->word_index, w->wordid, w->data);
 			}
 			/* FIXME: what to on error?  lost data? */
 			w->used = 0;
@@ -246,14 +249,14 @@ text_index_add_name_to_word(CamelIndex *idx, const gchar *word, camel_key_t name
 }
 
 static gint
-text_index_sync(CamelIndex *idx)
+text_index_sync (CamelIndex *idx)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	struct _CamelTextIndexWord *ww;
 	struct _CamelTextIndexRoot *rb;
 	gint ret = 0, wfrag, nfrag, work = FALSE;
 
-	d(printf("sync: blocks = %p\n", p->blocks));
+	d (printf ("sync: blocks = %p\n", p->blocks));
 
 	if (p->blocks == NULL || p->links == NULL
 	    || p->word_index == NULL || p->word_hash == NULL
@@ -264,93 +267,94 @@ text_index_sync(CamelIndex *idx)
 
 	/* sync/flush word cache */
 
-	CAMEL_TEXT_INDEX_LOCK(idx, lock);
+	CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
 	/* we sync, bump down the cache limits since we dont need them for reading */
 	p->blocks->block_cache_limit = 128;
 	/* this doesn't really need to be dropped, its only used in updates anyway */
 	p->word_cache_limit = 1024;
 
-	work = !camel_dlist_empty(&p->word_cache);
+	work = !camel_dlist_empty (&p->word_cache);
 
-	while ((ww = (struct _CamelTextIndexWord *)camel_dlist_remhead(&p->word_cache))) {
+	while ((ww = (struct _CamelTextIndexWord *)camel_dlist_remhead (&p->word_cache))) {
 		if (ww->used > 0) {
-			io(printf("writing key file entry '%s' [%x]\n", ww->word, ww->data));
-			if (camel_key_file_write(p->links, &ww->data, ww->used, ww->names) != -1) {
-				io(printf("  new data [%x]\n", ww->data));
+			io (printf ("writing key file entry '%s' [%x]\n", ww->word, ww->data));
+			if (camel_key_file_write (p->links, &ww->data, ww->used, ww->names) != -1) {
+				io (printf ("  new data [%x]\n", ww->data));
 				rb->keys++;
-				camel_block_file_touch_block(p->blocks, p->blocks->root_block);
-				camel_key_table_set_data(p->word_index, ww->wordid, ww->data);
+				camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+				camel_key_table_set_data (
+					p->word_index, ww->wordid, ww->data);
 			} else {
 				ret = -1;
 			}
 			ww->used = 0;
 		}
-		g_hash_table_remove(p->words, ww->word);
-		g_free(ww->word);
-		g_free(ww);
+		g_hash_table_remove (p->words, ww->word);
+		g_free (ww->word);
+		g_free (ww);
 	}
 
-	if (camel_key_table_sync(p->word_index) == -1
-	    || camel_key_table_sync(p->name_index) == -1
-	    || camel_partition_table_sync(p->word_hash) == -1
-	    || camel_partition_table_sync(p->name_hash) == -1)
+	if (camel_key_table_sync (p->word_index) == -1
+	    || camel_key_table_sync (p->name_index) == -1
+	    || camel_partition_table_sync (p->word_hash) == -1
+	    || camel_partition_table_sync (p->name_hash) == -1)
 		ret = -1;
 
 	/* only do the frag/compress check if we did some new writes on this index */
 	wfrag = rb->words ? (((rb->keys - rb->words) * 100)/ rb->words) : 0;
 	nfrag = rb->names ? ((rb->deleted * 100) / rb->names) : 0;
-	d(printf("wfrag = %d, nfrag = %d, work = %s, ret = %d\n", wfrag, nfrag, work?"true":"false", ret));
-	d(printf("  words = %d, keys = %d\n", rb->words, rb->keys));
+	d (printf ("wfrag = %d, nfrag = %d, work = %s, ret = %d\n", wfrag, nfrag, work?"true":"false", ret));
+	d (printf ("  words = %d, keys = %d\n", rb->words, rb->keys));
 
 	if (ret == 0) {
 		if (wfrag > 30 || nfrag > 20)
-			ret = text_index_compress_nosync(idx);
+			ret = text_index_compress_nosync (idx);
 	}
 
-	ret = camel_block_file_sync(p->blocks);
+	ret = camel_block_file_sync (p->blocks);
 
-	CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+	CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 
 	return ret;
 }
 
-static void tmp_name(const gchar *in, gchar *o)
+static void tmp_name (const gchar *in, gchar *o)
 {
 	gchar *s;
 
-	s = strrchr(in, '/');
+	s = strrchr (in, '/');
 	if (s) {
-		memcpy(o, in, s-in+1);
-		memcpy(o+(s-in+1), ".#", 2);
-		strcpy(o+(s-in+3), s+1);
+		memcpy (o, in, s-in+1);
+		memcpy (o+(s-in+1), ".#", 2);
+		strcpy (o+(s-in+3), s+1);
 	} else {
-		sprintf(o, ".#%s", in);
+		sprintf (o, ".#%s", in);
 	}
 }
 
 static gint
-text_index_compress(CamelIndex *idx)
+text_index_compress (CamelIndex *idx)
 {
 	gint ret;
 
-	CAMEL_TEXT_INDEX_LOCK(idx, lock);
+	CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
-	ret = camel_index_sync(idx);
+	ret = camel_index_sync (idx);
 	if (ret != -1)
-		ret = text_index_compress_nosync(idx);
+		ret = text_index_compress_nosync (idx);
 
-	CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+	CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 
 	return ret;
 }
 
 /* Attempt to recover index space by compressing the indices */
 static gint
-text_index_compress_nosync(CamelIndex *idx)
+text_index_compress_nosync (CamelIndex *idx)
 {
 	CamelTextIndex *newidx;
-	struct _CamelTextIndexPrivate *newp, *oldp;
+	CamelTextIndexPrivate *newp, *oldp;
 	camel_key_t oldkeyid, newkeyid;
 	GHashTable *remap;
 	guint deleted;
@@ -363,30 +367,30 @@ text_index_compress_nosync(CamelIndex *idx)
 	camel_key_t *records, newrecords[256];
 	struct _CamelTextIndexRoot *rb;
 
-	i = strlen(idx->path)+16;
-	oldpath = alloca(i);
-	newpath = alloca(i);
-	savepath = alloca(i);
+	i = strlen (idx->path)+16;
+	oldpath = alloca (i);
+	newpath = alloca (i);
+	savepath = alloca (i);
 
-	strcpy(oldpath, idx->path);
-	oldpath[strlen(oldpath)-strlen(".index")] = 0;
+	strcpy (oldpath, idx->path);
+	oldpath[strlen (oldpath)-strlen (".index")] = 0;
 
-	tmp_name(oldpath, newpath);
-	sprintf(savepath, "%s~", oldpath);
+	tmp_name (oldpath, newpath);
+	sprintf (savepath, "%s~", oldpath);
 
-	d(printf("Old index: %s\n", idx->path));
-	d(printf("Old path: %s\n", oldpath));
-	d(printf("New: %s\n", newpath));
-	d(printf("Save: %s\n", savepath));
+	d (printf ("Old index: %s\n", idx->path));
+	d (printf ("Old path: %s\n", oldpath));
+	d (printf ("New: %s\n", newpath));
+	d (printf ("Save: %s\n", savepath));
 
-	newidx = camel_text_index_new(newpath, O_RDWR|O_CREAT);
+	newidx = camel_text_index_new (newpath, O_RDWR|O_CREAT);
 	if (newidx == NULL)
 		return -1;
 
-	newp = CTI_PRIVATE(newidx);
-	oldp = CTI_PRIVATE(idx);
+	newp = CAMEL_TEXT_INDEX_GET_PRIVATE (newidx);
+	oldp = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 
-	CAMEL_TEXT_INDEX_LOCK(idx, lock);
+	CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
 	rb = (struct _CamelTextIndexRoot *)newp->blocks->root;
 
@@ -401,26 +405,28 @@ text_index_compress_nosync(CamelIndex *idx)
 
 	   For each word:
 	   Copy word's data to a new file
-	   Add new word to index(*) (can we just copy blocks?) */
+	   Add new word to index (*) (can we just copy blocks?) */
 
 	/* Copy undeleted names to new index file, creating new indices */
-	io(printf("Copying undeleted names to new file\n"));
-	remap = g_hash_table_new(NULL, NULL);
+	io (printf ("Copying undeleted names to new file\n"));
+	remap = g_hash_table_new (NULL, NULL);
 	oldkeyid = 0;
 	deleted = 0;
-	while ((oldkeyid = camel_key_table_next(oldp->name_index, oldkeyid, &name, &flags, &data))) {
+	while ((oldkeyid = camel_key_table_next (oldp->name_index, oldkeyid, &name, &flags, &data))) {
 		if ((flags&1) == 0) {
-			io(printf("copying name '%s'\n", name));
-			newkeyid = camel_key_table_add(newp->name_index, name, data, flags);
+			io (printf ("copying name '%s'\n", name));
+			newkeyid = camel_key_table_add (
+				newp->name_index, name, data, flags);
 			if (newkeyid == 0)
 				goto fail;
 			rb->names++;
-			camel_partition_table_add(newp->name_hash, name, newkeyid);
-			g_hash_table_insert(remap, GINT_TO_POINTER(oldkeyid), GINT_TO_POINTER(newkeyid));
+			camel_partition_table_add (
+				newp->name_hash, name, newkeyid);
+			g_hash_table_insert (remap, GINT_TO_POINTER (oldkeyid), GINT_TO_POINTER (newkeyid));
 		} else {
-			io(printf("deleted name '%s'\n", name));
+			io (printf ("deleted name '%s'\n", name));
 		}
-		g_free(name);
+		g_free (name);
 		name = NULL;
 		deleted |= flags;
 	}
@@ -429,8 +435,8 @@ text_index_compress_nosync(CamelIndex *idx)
 	/* We re-block the data into 256 entry lots while we're at it, since we only
 	   have to do 1 at a time and its cheap */
 	oldkeyid = 0;
-	while ((oldkeyid = camel_key_table_next(oldp->word_index, oldkeyid, &name, &flags, &data))) {
-		io(printf("copying word '%s'\n", name));
+	while ((oldkeyid = camel_key_table_next (oldp->word_index, oldkeyid, &name, &flags, &data))) {
+		io(printf ("copying word '%s'\n", name));
 		newdata = 0;
 		newcount = 0;
 		if (data) {
@@ -438,153 +444,155 @@ text_index_compress_nosync(CamelIndex *idx)
 			rb->keys++;
 		}
 		while (data) {
-			if (camel_key_file_read(oldp->links, &data, &count, &records) == -1) {
-				io(printf("could not read from old keys at %d for word '%s'\n", (gint)data, name));
+			if (camel_key_file_read (oldp->links, &data, &count, &records) == -1) {
+				io (printf ("could not read from old keys at %d for word '%s'\n", (gint)data, name));
 				goto fail;
 			}
 			for (i=0;i<count;i++) {
-				newkeyid = (camel_key_t)GPOINTER_TO_INT(g_hash_table_lookup(remap, GINT_TO_POINTER(records[i])));
+				newkeyid = (camel_key_t)GPOINTER_TO_INT (g_hash_table_lookup (remap, GINT_TO_POINTER (records[i])));
 				if (newkeyid) {
 					newrecords[newcount++] = newkeyid;
 					if (newcount == G_N_ELEMENTS (newrecords)) {
-						if (camel_key_file_write(newp->links, &newdata, newcount, newrecords) == -1) {
-							g_free(records);
+						if (camel_key_file_write (newp->links, &newdata, newcount, newrecords) == -1) {
+							g_free (records);
 							goto fail;
 						}
 						newcount = 0;
 					}
 				}
 			}
-			g_free(records);
+			g_free (records);
 		}
 
 		if (newcount > 0) {
-			if (camel_key_file_write(newp->links, &newdata, newcount, newrecords) == -1)
+			if (camel_key_file_write (newp->links, &newdata, newcount, newrecords) == -1)
 				goto fail;
 		}
 
 		if (newdata != 0) {
-			newkeyid = camel_key_table_add(newp->word_index, name, newdata, flags);
+			newkeyid = camel_key_table_add (
+				newp->word_index, name, newdata, flags);
 			if (newkeyid == 0)
 				goto fail;
-			camel_partition_table_add(newp->word_hash, name, newkeyid);
+			camel_partition_table_add (
+				newp->word_hash, name, newkeyid);
 		}
-		g_free(name);
+		g_free (name);
 		name = NULL;
 	}
 
-	camel_block_file_touch_block(newp->blocks, newp->blocks->root_block);
+	camel_block_file_touch_block (newp->blocks, newp->blocks->root_block);
 
-	if (camel_index_sync((CamelIndex *)newidx) == -1)
+	if (camel_index_sync (CAMEL_INDEX (newidx)) == -1)
 		goto fail;
 
 	/* Rename underlying files to match */
-	ret = camel_index_rename(idx, savepath);
+	ret = camel_index_rename (idx, savepath);
 	if (ret == -1)
 		goto fail;
 
 	/* If this fails, we'll pick up something during restart? */
-	ret = camel_index_rename((CamelIndex *)newidx, oldpath);
+	ret = camel_index_rename ((CamelIndex *)newidx, oldpath);
 
 #define myswap(a, b) { gpointer tmp = a; a = b; b = tmp; }
 	/* Poke the private data across to the new object */
 	/* And change the fd's over, etc? */
 	/* Yes: This is a hack */
-	myswap(newp->blocks, oldp->blocks);
-	myswap(newp->links, oldp->links);
-	myswap(newp->word_index, oldp->word_index);
-	myswap(newp->word_hash, oldp->word_hash);
-	myswap(newp->name_index, oldp->name_index);
-	myswap(newp->name_hash, oldp->name_hash);
-	myswap(((CamelIndex *)newidx)->path, ((CamelIndex *)idx)->path);
+	myswap (newp->blocks, oldp->blocks);
+	myswap (newp->links, oldp->links);
+	myswap (newp->word_index, oldp->word_index);
+	myswap (newp->word_hash, oldp->word_hash);
+	myswap (newp->name_index, oldp->name_index);
+	myswap (newp->name_hash, oldp->name_hash);
+	myswap (((CamelIndex *)newidx)->path, ((CamelIndex *)idx)->path);
 #undef myswap
 
 	ret = 0;
 fail:
-	CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+	CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 
-	camel_index_delete((CamelIndex *)newidx);
+	camel_index_delete ((CamelIndex *)newidx);
 
-	camel_object_unref((CamelObject *)newidx);
-	g_free(name);
-	g_hash_table_destroy(remap);
+	camel_object_unref (newidx);
+	g_free (name);
+	g_hash_table_destroy (remap);
 
 	/* clean up temp files always */
-	sprintf(savepath, "%s~.index", oldpath);
-	g_unlink(savepath);
-	sprintf(newpath, "%s.data", savepath);
-	g_unlink(newpath);
+	sprintf (savepath, "%s~.index", oldpath);
+	g_unlink (savepath);
+	sprintf (newpath, "%s.data", savepath);
+	g_unlink (newpath);
 
 	return ret;
 }
 
 static gint
-text_index_delete(CamelIndex *idx)
+text_index_delete (CamelIndex *idx)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	gint ret = 0;
 
-	if (camel_block_file_delete(p->blocks) == -1)
+	if (camel_block_file_delete (p->blocks) == -1)
 		ret = -1;
-	if (camel_key_file_delete(p->links) == -1)
+	if (camel_key_file_delete (p->links) == -1)
 		ret = -1;
 
 	return ret;
 }
 
 static gint
-text_index_rename(CamelIndex *idx, const gchar *path)
+text_index_rename (CamelIndex *idx, const gchar *path)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	gchar *newlink, *newblock;
 	gint err, ret;
 
-	CAMEL_TEXT_INDEX_LOCK(idx, lock);
+	CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
-	newblock = alloca(strlen(path)+8);
-	sprintf(newblock, "%s.index", path);
-	ret = camel_block_file_rename(p->blocks, newblock);
+	newblock = alloca (strlen (path)+8);
+	sprintf (newblock, "%s.index", path);
+	ret = camel_block_file_rename (p->blocks, newblock);
 	if (ret == -1) {
-		CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+		CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 		return -1;
 	}
 
-	newlink = alloca(strlen(path)+16);
-	sprintf(newlink, "%s.index.data", path);
-	ret = camel_key_file_rename(p->links, newlink);
+	newlink = alloca (strlen (path)+16);
+	sprintf (newlink, "%s.index.data", path);
+	ret = camel_key_file_rename (p->links, newlink);
 	if (ret == -1) {
 		err = errno;
-		camel_block_file_rename(p->blocks, idx->path);
-		CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+		camel_block_file_rename (p->blocks, idx->path);
+		CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 		errno = err;
 		return -1;
 	}
 
-	g_free(idx->path);
-	idx->path = g_strdup(newblock);
+	g_free (idx->path);
+	idx->path = g_strdup (newblock);
 
-	CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+	CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 
 	return 0;
 }
 
 static gint
-text_index_has_name(CamelIndex *idx, const gchar *name)
+text_index_has_name (CamelIndex *idx, const gchar *name)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 
-	return camel_partition_table_lookup(p->name_hash, name) != 0;
+	return camel_partition_table_lookup (p->name_hash, name) != 0;
 }
 
 static CamelIndexName *
-text_index_add_name(CamelIndex *idx, const gchar *name)
+text_index_add_name (CamelIndex *idx, const gchar *name)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	camel_key_t keyid;
 	CamelIndexName *idn;
 	struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *)p->blocks->root;
 
-	CAMEL_TEXT_INDEX_LOCK(idx, lock);
+	CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
 	/* if we're adding words, up the cache limits a lot */
 	if (p->blocks) {
@@ -593,138 +601,139 @@ text_index_add_name(CamelIndex *idx, const gchar *name)
 	}
 
 	/* If we have it already replace it */
-	keyid = camel_partition_table_lookup(p->name_hash, name);
+	keyid = camel_partition_table_lookup (p->name_hash, name);
 	if (keyid != 0) {
 		/* TODO: We could just update the partition table's
 		   key pointer rather than having to delete it */
 		rb->deleted++;
-		camel_key_table_set_flags(p->name_index, keyid, 1, 1);
-		camel_partition_table_remove(p->name_hash, name);
+		camel_key_table_set_flags (p->name_index, keyid, 1, 1);
+		camel_partition_table_remove (p->name_hash, name);
 	}
 
-	keyid = camel_key_table_add(p->name_index, name, 0, 0);
+	keyid = camel_key_table_add (p->name_index, name, 0, 0);
 	if (keyid != 0) {
-		camel_partition_table_add(p->name_hash, name, keyid);
+		camel_partition_table_add (p->name_hash, name, keyid);
 		rb->names++;
 	}
 
-	camel_block_file_touch_block(p->blocks, p->blocks->root_block);
+	camel_block_file_touch_block (p->blocks, p->blocks->root_block);
 
 	/* TODO: if keyid == 0, we had a failure, we should somehow flag that, but for
 	   now just return a valid object but discard its results, see text_index_write_name */
 
-	CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+	CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 
-	idn = (CamelIndexName *)camel_text_index_name_new((CamelTextIndex *)idx, name, keyid);
+	idn = (CamelIndexName *)camel_text_index_name_new ((CamelTextIndex *)idx, name, keyid);
 
 	return idn;
 }
 
 /* call locked */
 static void
-hash_write_word(gchar *word, gpointer data, CamelIndexName *idn)
+hash_write_word (gchar *word, gpointer data, CamelIndexName *idn)
 {
 	CamelTextIndexName *tin = (CamelTextIndexName *)idn;
 
-	text_index_add_name_to_word(idn->index, word, tin->priv->nameid);
+	text_index_add_name_to_word (idn->index, word, tin->priv->nameid);
 }
 
 static gint
-text_index_write_name(CamelIndex *idx, CamelIndexName *idn)
+text_index_write_name (CamelIndex *idx, CamelIndexName *idn)
 {
 	/* force 'flush' of any outstanding data */
-	camel_index_name_add_buffer(idn, NULL, 0);
+	camel_index_name_add_buffer (idn, NULL, 0);
 
 	/* see text_index_add_name for when this can be 0 */
 	if (((CamelTextIndexName *)idn)->priv->nameid != 0) {
-		CAMEL_TEXT_INDEX_LOCK(idx, lock);
+		CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
-		g_hash_table_foreach(idn->words, (GHFunc)hash_write_word, idn);
+		g_hash_table_foreach (idn->words, (GHFunc)hash_write_word, idn);
 
-		CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+		CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 	}
 
 	return 0;
 }
 
 static CamelIndexCursor *
-text_index_find_name(CamelIndex *idx, const gchar *name)
+text_index_find_name (CamelIndex *idx, const gchar *name)
 {
 	/* what was this for, umm */
 	return NULL;
 }
 
 static void
-text_index_delete_name(CamelIndex *idx, const gchar *name)
+text_index_delete_name (CamelIndex *idx, const gchar *name)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	camel_key_t keyid;
 	struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *)p->blocks->root;
 
-	d(printf("Delete name: %s\n", name));
+	d (printf ("Delete name: %s\n", name));
 
 	/* probably doesn't really need locking, but oh well */
-	CAMEL_TEXT_INDEX_LOCK(idx, lock);
+	CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
 	/* We just mark the key deleted, and remove it from the hash table */
-	keyid = camel_partition_table_lookup(p->name_hash, name);
+	keyid = camel_partition_table_lookup (p->name_hash, name);
 	if (keyid != 0) {
 		rb->deleted++;
-		camel_block_file_touch_block(p->blocks, p->blocks->root_block);
-		camel_key_table_set_flags(p->name_index, keyid, 1, 1);
-		camel_partition_table_remove(p->name_hash, name);
+		camel_block_file_touch_block (p->blocks, p->blocks->root_block);
+		camel_key_table_set_flags (p->name_index, keyid, 1, 1);
+		camel_partition_table_remove (p->name_hash, name);
 	}
 
-	CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+	CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 }
 
 static CamelIndexCursor *
-text_index_find(CamelIndex *idx, const gchar *word)
+text_index_find (CamelIndex *idx, const gchar *word)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	camel_key_t keyid;
 	camel_block_t data = 0;
 	guint flags;
 	CamelIndexCursor *idc;
 
-	CAMEL_TEXT_INDEX_LOCK(idx, lock);
+	CAMEL_TEXT_INDEX_LOCK (idx, lock);
 
-	keyid = camel_partition_table_lookup(p->word_hash, word);
+	keyid = camel_partition_table_lookup (p->word_hash, word);
 	if (keyid != 0) {
-		data = camel_key_table_lookup(p->word_index, keyid, NULL, &flags);
+		data = camel_key_table_lookup (
+			p->word_index, keyid, NULL, &flags);
 		if (flags & 1)
 			data = 0;
 	}
 
-	CAMEL_TEXT_INDEX_UNLOCK(idx, lock);
+	CAMEL_TEXT_INDEX_UNLOCK (idx, lock);
 
-	idc = (CamelIndexCursor *)camel_text_index_cursor_new((CamelTextIndex *)idx, data);
+	idc = (CamelIndexCursor *)camel_text_index_cursor_new ((CamelTextIndex *)idx, data);
 
 	return idc;
 }
 
 static CamelIndexCursor *
-text_index_words(CamelIndex *idx)
+text_index_words (CamelIndex *idx)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 
-	return (CamelIndexCursor *)camel_text_index_key_cursor_new((CamelTextIndex *)idx, p->word_index);
+	return (CamelIndexCursor *)camel_text_index_key_cursor_new ((CamelTextIndex *)idx, p->word_index);
 }
 
 static CamelIndexCursor *
-text_index_names(CamelIndex *idx)
+text_index_names (CamelIndex *idx)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 
-	return (CamelIndexCursor *)camel_text_index_key_cursor_new((CamelTextIndex *)idx, p->name_index);
+	return (CamelIndexCursor *)camel_text_index_key_cursor_new ((CamelTextIndex *)idx, p->name_index);
 }
 
 static void
-camel_text_index_class_init(CamelTextIndexClass *klass)
+camel_text_index_class_init (CamelTextIndexClass *klass)
 {
 	CamelIndexClass *iklass = (CamelIndexClass *)klass;
 
-	camel_text_index_parent = CAMEL_OBJECT_CLASS(camel_type_get_global_classfuncs(camel_object_get_type()));
+	camel_text_index_parent = CAMEL_OBJECT_CLASS (camel_type_get_global_classfuncs (camel_object_get_type ()));
 
 	iklass->sync = text_index_sync;
 	iklass->compress = text_index_compress;
@@ -744,60 +753,60 @@ camel_text_index_class_init(CamelTextIndexClass *klass)
 }
 
 static void
-camel_text_index_init(CamelTextIndex *idx)
+camel_text_index_init (CamelTextIndex *idx)
 {
-	struct _CamelTextIndexPrivate *p;
+	CamelTextIndexPrivate *p;
 
-	p = CTI_PRIVATE(idx) = g_malloc0(sizeof(*p));
+	p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx) = g_malloc0(sizeof (*p));
 
-	camel_dlist_init(&p->word_cache);
-	p->words = g_hash_table_new(g_str_hash, g_str_equal);
+	camel_dlist_init (&p->word_cache);
+	p->words = g_hash_table_new (g_str_hash, g_str_equal);
 	p->word_cache_count = 0;
 	/* this cache size and the block cache size have been tuned for about the best
 	   with moderate memory usage.  Doubling the memory usage barely affects performance. */
 	p->word_cache_limit = 4096; /* 1024 = 128K */
 
-	g_static_rec_mutex_init(&p->lock);
+	g_static_rec_mutex_init (&p->lock);
 }
 
 static void
-camel_text_index_finalize(CamelTextIndex *idx)
+camel_text_index_finalize (CamelTextIndex *idx)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 
-	camel_index_sync((CamelIndex *)idx);
+	camel_index_sync ((CamelIndex *)idx);
 
-	g_assert(camel_dlist_empty(&p->word_cache));
-	g_assert(g_hash_table_size(p->words) == 0);
+	g_assert (camel_dlist_empty (&p->word_cache));
+	g_assert (g_hash_table_size (p->words) == 0);
 
-	g_hash_table_destroy(p->words);
+	g_hash_table_destroy (p->words);
 
 	if (p->word_index)
-		camel_object_unref((CamelObject *)p->word_index);
+		camel_object_unref (p->word_index);
 	if (p->word_hash)
-		camel_object_unref((CamelObject *)p->word_hash);
+		camel_object_unref (p->word_hash);
 	if (p->name_index)
-		camel_object_unref((CamelObject *)p->name_index);
+		camel_object_unref (p->name_index);
 	if (p->name_hash)
-		camel_object_unref((CamelObject *)p->name_hash);
+		camel_object_unref (p->name_hash);
 
 	if (p->blocks)
-		camel_object_unref((CamelObject *)p->blocks);
+		camel_object_unref (p->blocks);
 	if (p->links)
-		camel_object_unref((CamelObject *)p->links);
+		camel_object_unref (p->links);
 
-	g_static_rec_mutex_free(&p->lock);
+	g_static_rec_mutex_free (&p->lock);
 
-	g_free(p);
+	g_free (p);
 }
 
 CamelType
-camel_text_index_get_type(void)
+camel_text_index_get_type (void)
 {
 	static CamelType type = CAMEL_INVALID_TYPE;
 
 	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register(camel_index_get_type(), "CamelTextIndex",
+		type = camel_type_register (camel_index_get_type (), "CamelTextIndex",
 					   sizeof (CamelTextIndex),
 					   sizeof (CamelTextIndexClass),
 					   (CamelObjectClassInitFunc) camel_text_index_class_init,
@@ -810,155 +819,159 @@ camel_text_index_get_type(void)
 }
 
 static gchar *
-text_index_normalize(CamelIndex *idx, const gchar *in, gpointer data)
+text_index_normalize (CamelIndex *idx, const gchar *in, gpointer data)
 {
 	gchar *word;
 
 	/* Sigh, this is really expensive */
-	/*g_utf8_normalize(in, strlen(in), G_NORMALIZE_ALL);*/
-	word = g_utf8_strdown(in, -1);
+	/*g_utf8_normalize (in, strlen (in), G_NORMALIZE_ALL);*/
+	word = g_utf8_strdown (in, -1);
 
 	return word;
 }
 
 CamelTextIndex *
-camel_text_index_new(const gchar *path, gint flags)
+camel_text_index_new (const gchar *path, gint flags)
 {
-	CamelTextIndex *idx = (CamelTextIndex *)camel_object_new(camel_text_index_get_type());
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndex *idx = (CamelTextIndex *)camel_object_new (camel_text_index_get_type ());
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	struct _CamelTextIndexRoot *rb;
 	gchar *link;
 	CamelBlock *bl;
 
-	camel_index_construct((CamelIndex *)idx, path, flags);
-	camel_index_set_normalize((CamelIndex *)idx, text_index_normalize, NULL);
+	camel_index_construct ((CamelIndex *)idx, path, flags);
+	camel_index_set_normalize ((CamelIndex *)idx, text_index_normalize, NULL);
 
-	p->blocks = camel_block_file_new(idx->parent.path, flags, CAMEL_TEXT_INDEX_VERSION, CAMEL_BLOCK_SIZE);
-	link = alloca(strlen(idx->parent.path)+7);
-	sprintf(link, "%s.data", idx->parent.path);
-	p->links = camel_key_file_new(link, flags, CAMEL_TEXT_INDEX_KEY_VERSION);
+	p->blocks = camel_block_file_new (
+		idx->parent.path, flags, CAMEL_TEXT_INDEX_VERSION, CAMEL_BLOCK_SIZE);
+	if (p->blocks == NULL)
+		goto fail;
+
+	link = alloca (strlen (idx->parent.path)+7);
+	sprintf (link, "%s.data", idx->parent.path);
+	p->links = camel_key_file_new (link, flags, CAMEL_TEXT_INDEX_KEY_VERSION);
 
-	if (p->blocks == NULL || p->links == NULL)
+	if (p->links == NULL)
 		goto fail;
 
 	rb = (struct _CamelTextIndexRoot *)p->blocks->root;
 
 	if (rb->word_index_root == 0) {
-		bl = camel_block_file_new_block(p->blocks);
+		bl = camel_block_file_new_block (p->blocks);
 
 		if (bl == NULL)
 			goto fail;
 
 		rb->word_index_root = bl->id;
-		camel_block_file_unref_block(p->blocks, bl);
-		camel_block_file_touch_block(p->blocks, p->blocks->root_block);
+		camel_block_file_unref_block (p->blocks, bl);
+		camel_block_file_touch_block (p->blocks, p->blocks->root_block);
 	}
 
 	if (rb->word_hash_root == 0) {
-		bl = camel_block_file_new_block(p->blocks);
+		bl = camel_block_file_new_block (p->blocks);
 
 		if (bl == NULL)
 			goto fail;
 
 		rb->word_hash_root = bl->id;
-		camel_block_file_unref_block(p->blocks, bl);
-		camel_block_file_touch_block(p->blocks, p->blocks->root_block);
+		camel_block_file_unref_block (p->blocks, bl);
+		camel_block_file_touch_block (p->blocks, p->blocks->root_block);
 	}
 
 	if (rb->name_index_root == 0) {
-		bl = camel_block_file_new_block(p->blocks);
+		bl = camel_block_file_new_block (p->blocks);
 
 		if (bl == NULL)
 			goto fail;
 
 		rb->name_index_root = bl->id;
-		camel_block_file_unref_block(p->blocks, bl);
-		camel_block_file_touch_block(p->blocks, p->blocks->root_block);
+		camel_block_file_unref_block (p->blocks, bl);
+		camel_block_file_touch_block (p->blocks, p->blocks->root_block);
 	}
 
 	if (rb->name_hash_root == 0) {
-		bl = camel_block_file_new_block(p->blocks);
+		bl = camel_block_file_new_block (p->blocks);
 
 		if (bl == NULL)
 			goto fail;
 
 		rb->name_hash_root = bl->id;
-		camel_block_file_unref_block(p->blocks, bl);
-		camel_block_file_touch_block(p->blocks, p->blocks->root_block);
+		camel_block_file_unref_block (p->blocks, bl);
+		camel_block_file_touch_block (p->blocks, p->blocks->root_block);
 	}
 
-	p->word_index = camel_key_table_new(p->blocks, rb->word_index_root);
-	p->word_hash = camel_partition_table_new(p->blocks, rb->word_hash_root);
-	p->name_index = camel_key_table_new(p->blocks, rb->name_index_root);
-	p->name_hash = camel_partition_table_new(p->blocks, rb->name_hash_root);
+	p->word_index = camel_key_table_new (p->blocks, rb->word_index_root);
+	p->word_hash = camel_partition_table_new (p->blocks, rb->word_hash_root);
+	p->name_index = camel_key_table_new (p->blocks, rb->name_index_root);
+	p->name_hash = camel_partition_table_new (p->blocks, rb->name_hash_root);
 
 	if (p->word_index == NULL || p->word_hash == NULL
 	    || p->name_index == NULL || p->name_hash == NULL) {
-		camel_object_unref((CamelObject *)idx);
+		camel_object_unref (idx);
 		idx = NULL;
 	}
 
 	return idx;
 
 fail:
-	camel_object_unref((CamelObject *)idx);
+	camel_object_unref (idx);
 	return NULL;
 }
 
 /* returns 0 if the index exists, is valid, and synced, -1 otherwise */
 gint
-camel_text_index_check(const gchar *path)
+camel_text_index_check (const gchar *path)
 {
 	gchar *block, *key;
 	CamelBlockFile *blocks;
 	CamelKeyFile *keys;
 
-	block = alloca(strlen(path)+7);
-	sprintf(block, "%s.index", path);
-	blocks = camel_block_file_new(block, O_RDONLY, CAMEL_TEXT_INDEX_VERSION, CAMEL_BLOCK_SIZE);
+	block = alloca (strlen (path)+7);
+	sprintf (block, "%s.index", path);
+	blocks = camel_block_file_new (block, O_RDONLY, CAMEL_TEXT_INDEX_VERSION, CAMEL_BLOCK_SIZE);
 	if (blocks == NULL) {
-		io(printf("Check failed: No block file: %s\n", g_strerror (errno)));
+		io (printf ("Check failed: No block file: %s\n", g_strerror (errno)));
 		return -1;
 	}
-	key = alloca(strlen(path)+12);
-	sprintf(key, "%s.index.data", path);
-	keys = camel_key_file_new(key, O_RDONLY, CAMEL_TEXT_INDEX_KEY_VERSION);
+	key = alloca (strlen (path)+12);
+	sprintf (key, "%s.index.data", path);
+	keys = camel_key_file_new (key, O_RDONLY, CAMEL_TEXT_INDEX_KEY_VERSION);
 	if (keys == NULL) {
-		io(printf("Check failed: No key file: %s\n", g_strerror (errno)));
-		camel_object_unref((CamelObject *)blocks);
+		io (printf ("Check failed: No key file: %s\n", g_strerror (errno)));
+		camel_object_unref (blocks);
 		return -1;
 	}
 
-	camel_object_unref((CamelObject *)keys);
-	camel_object_unref((CamelObject *)blocks);
+	camel_object_unref (keys);
+	camel_object_unref (blocks);
 
 	return 0;
 }
 
 gint
-camel_text_index_rename(const gchar *old, const gchar *new)
+camel_text_index_rename (const gchar *old, const gchar *new)
 {
 	gchar *oldname, *newname;
 	gint err;
 
 	/* TODO: camel_text_index_rename should find out if we have an active index and use that instead */
 
-	oldname = alloca(strlen(old)+12);
-	newname = alloca(strlen(new)+12);
-	sprintf(oldname, "%s.index", old);
-	sprintf(newname, "%s.index", new);
+	oldname = alloca (strlen (old)+12);
+	newname = alloca (strlen (new)+12);
+	sprintf (oldname, "%s.index", old);
+	sprintf (newname, "%s.index", new);
 
-	if (g_rename(oldname, newname) == -1 && errno != ENOENT)
+	if (g_rename (oldname, newname) == -1 && errno != ENOENT)
 		return -1;
 
-	sprintf(oldname, "%s.index.data", old);
-	sprintf(newname, "%s.index.data", new);
+	sprintf (oldname, "%s.index.data", old);
+	sprintf (newname, "%s.index.data", new);
 
-	if (g_rename(oldname, newname) == -1 && errno != ENOENT) {
+	if (g_rename (oldname, newname) == -1 && errno != ENOENT) {
 		err = errno;
-		sprintf(oldname, "%s.index", old);
-		sprintf(newname, "%s.index", new);
-		g_rename(newname, oldname);
+		sprintf (oldname, "%s.index", old);
+		sprintf (newname, "%s.index", new);
+		g_rename (newname, oldname);
 		errno = err;
 		return -1;
 	}
@@ -967,21 +980,21 @@ camel_text_index_rename(const gchar *old, const gchar *new)
 }
 
 gint
-camel_text_index_remove(const gchar *old)
+camel_text_index_remove (const gchar *old)
 {
 	gchar *block, *key;
 	gint ret = 0;
 
 	/* TODO: needs to poke any active indices to remain unlinked */
 
-	block = alloca(strlen(old)+12);
-	key = alloca(strlen(old)+12);
-	sprintf(block, "%s.index", old);
-	sprintf(key, "%s.index.data", old);
+	block = alloca (strlen (old)+12);
+	key = alloca (strlen (old)+12);
+	sprintf (block, "%s.index", old);
+	sprintf (key, "%s.index.data", old);
 
-	if (g_unlink(block) == -1 && errno != ENOENT)
+	if (g_unlink (block) == -1 && errno != ENOENT)
 		ret = -1;
-	if (g_unlink(key) == -1 && errno != ENOENT)
+	if (g_unlink (key) == -1 && errno != ENOENT)
 		ret = -1;
 
 	return ret;
@@ -989,28 +1002,28 @@ camel_text_index_remove(const gchar *old)
 
 /* Debug */
 void
-camel_text_index_info(CamelTextIndex *idx)
+camel_text_index_info (CamelTextIndex *idx)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	struct _CamelTextIndexRoot *rb = (struct _CamelTextIndexRoot *)p->blocks->root;
 	gint frag;
 
-	printf("Path: '%s'\n", idx->parent.path);
-	printf("Version: %u\n", idx->parent.version);
-	printf("Flags: %08x\n", idx->parent.flags);
-	printf("Total words: %u\n", rb->words);
-	printf("Total names: %u\n", rb->names);
-	printf("Total deleted: %u\n", rb->deleted);
-	printf("Total key blocks: %u\n", rb->keys);
+	printf ("Path: '%s'\n", idx->parent.path);
+	printf ("Version: %u\n", idx->parent.version);
+	printf ("Flags: %08x\n", idx->parent.flags);
+	printf ("Total words: %u\n", rb->words);
+	printf ("Total names: %u\n", rb->names);
+	printf ("Total deleted: %u\n", rb->deleted);
+	printf ("Total key blocks: %u\n", rb->keys);
 
 	if (rb->words > 0) {
 		frag = ((rb->keys - rb->words) * 100)/ rb->words;
-		printf("Word fragmentation: %d%%\n", frag);
+		printf ("Word fragmentation: %d%%\n", frag);
 	}
 
 	if (rb->names > 0) {
 		frag = (rb->deleted * 100)/ rb->names;
-		printf("Name fragmentation: %d%%\n", frag);
+		printf ("Name fragmentation: %d%%\n", frag);
 	}
 }
 
@@ -1020,83 +1033,83 @@ camel_text_index_info(CamelTextIndex *idx)
 enum { KEY_ROOT = 1, KEY_DATA = 2, PARTITION_MAP = 4, PARTITION_DATA = 8 };
 
 static void
-add_type(GHashTable *map, camel_block_t id, gint type)
+add_type (GHashTable *map, camel_block_t id, gint type)
 {
 	camel_block_t old;
 
-	old = g_hash_table_lookup(map, id);
+	old = g_hash_table_lookup (map, id);
 	if (old == type)
 		return;
 
 	if (old != 0 && old != type)
-		g_warning("block %x redefined as type %d, already type %d\n", id, type, old);
-	g_hash_table_insert(map, id, GINT_TO_POINTER (type|old));
+		g_warning ("block %x redefined as type %d, already type %d\n", id, type, old);
+	g_hash_table_insert (map, id, GINT_TO_POINTER (type|old));
 }
 
 static void
-add_partition(GHashTable *map, CamelBlockFile *blocks, camel_block_t id)
+add_partition (GHashTable *map, CamelBlockFile *blocks, camel_block_t id)
 {
 	CamelBlock *bl;
 	CamelPartitionMapBlock *pm;
 	gint i;
 
 	while (id) {
-		add_type(map, id, PARTITION_MAP);
-		bl = camel_block_file_get_block(blocks, id);
+		add_type (map, id, PARTITION_MAP);
+		bl = camel_block_file_get_block (blocks, id);
 		if (bl == NULL) {
-			g_warning("couldn't get parition: %x\n", id);
+			g_warning ("couldn't get parition: %x\n", id);
 			return;
 		}
 
 		pm = (CamelPartitionMapBlock *)&bl->data;
 		if (pm->used > G_N_ELEMENTS (pm->partition)) {
-			g_warning("Partition block %x invalid\n", id);
-			camel_block_file_unref_block(blocks, bl);
+			g_warning ("Partition block %x invalid\n", id);
+			camel_block_file_unref_block (blocks, bl);
 			return;
 		}
 
 		for (i=0;i<pm->used;i++)
-			add_type(map, pm->partition[i].blockid, PARTITION_DATA);
+			add_type (map, pm->partition[i].blockid, PARTITION_DATA);
 
 		id = pm->next;
-		camel_block_file_unref_block(blocks, bl);
+		camel_block_file_unref_block (blocks, bl);
 	}
 }
 
 static void
-add_keys(GHashTable *map, CamelBlockFile *blocks, camel_block_t id)
+add_keys (GHashTable *map, CamelBlockFile *blocks, camel_block_t id)
 {
 	CamelBlock *rbl, *bl;
 	CamelKeyRootBlock *root;
 	CamelKeyBlock *kb;
 
-	add_type(map, id, KEY_ROOT);
-	rbl = camel_block_file_get_block(blocks, id);
+	add_type (map, id, KEY_ROOT);
+	rbl = camel_block_file_get_block (blocks, id);
 	if (rbl == NULL) {
-		g_warning("couldn't get key root: %x\n", id);
+		g_warning ("couldn't get key root: %x\n", id);
 		return;
 	}
 	root = (CamelKeyRootBlock *)&rbl->data;
 	id = root->first;
 
 	while (id) {
-		add_type(map, id, KEY_DATA);
-		bl = camel_block_file_get_block(blocks, id);
+		add_type (map, id, KEY_DATA);
+		bl = camel_block_file_get_block (blocks, id);
 		if (bl == NULL) {
-			g_warning("couldn't get key: %x\n", id);
+			g_warning ("couldn't get key: %x\n", id);
 			break;
 		}
 
 		kb = (CamelKeyBlock *)&bl->data;
 		id = kb->next;
-		camel_block_file_unref_block(blocks, bl);
+		camel_block_file_unref_block (blocks, bl);
 	}
 
-	camel_block_file_unref_block(blocks, rbl);
+	camel_block_file_unref_block (blocks, rbl);
 }
 
 static void
-dump_raw(GHashTable *map, gchar *path)
+dump_raw (GHashTable *map, gchar *path)
 {
 	gchar buf[1024];
 	gchar line[256];
@@ -1106,70 +1119,70 @@ dump_raw(GHashTable *map, gchar *path)
 	gint fd;
 	camel_block_t id, total;
 
-	fd = g_open(path, O_RDONLY|O_BINARY, 0);
+	fd = g_open (path, O_RDONLY|O_BINARY, 0);
 	if (fd == -1)
 		return;
 
 	total = 0;
-	while ((len = read(fd, buf, 1024)) == 1024) {
+	while ((len = read (fd, buf, 1024)) == 1024) {
 		id = total;
 
-		type = g_hash_table_lookup(map, id);
+		type = g_hash_table_lookup (map, id);
 		switch (type) {
 		case 0:
-			printf(" - unknown -\n");
+			printf (" - unknown -\n");
 			break;
 		default:
-			printf(" - invalid -\n");
+			printf (" - invalid -\n");
 			break;
 		case KEY_ROOT: {
 			CamelKeyRootBlock *r = (CamelKeyRootBlock *)buf;
-			printf("Key root:\n");
-			printf("First: %08x     Last: %08x     Free: %08x\n", r->first, r->last, r->free);
+			printf ("Key root:\n");
+			printf ("First: %08x     Last: %08x     Free: %08x\n", r->first, r->last, r->free);
 		} break;
 		case KEY_DATA: {
 			CamelKeyBlock *k = (CamelKeyBlock *)buf;
-			printf("Key data:\n");
-			printf("Next: %08x      Used: %u\n", k->next, k->used);
+			printf ("Key data:\n");
+			printf ("Next: %08x      Used: %u\n", k->next, k->used);
 			for (i=0;i<k->used;i++) {
 				if (i == 0)
-					len = sizeof(k->u.keydata);
+					len = sizeof (k->u.keydata);
 				else
 					len = k->u.keys[i-1].offset;
 				len -= k->u.keys[i].offset;
-				printf("[%03d]: %08x %5d %06x %3d '%.*s'\n", i,
+				printf ("[%03d]: %08x %5d %06x %3d '%.*s'\n", i,
 				       k->u.keys[i].data, k->u.keys[i].offset, k->u.keys[i].flags,
 				       len, len, k->u.keydata+k->u.keys[i].offset);
 			}
 		} break;
 		case PARTITION_MAP: {
 			CamelPartitionMapBlock *m = (CamelPartitionMapBlock *)buf;
-			printf("Partition map\n");
-			printf("Next: %08x      Used: %u\n", m->next, m->used);
+			printf ("Partition map\n");
+			printf ("Next: %08x      Used: %u\n", m->next, m->used);
 			for (i=0;i<m->used;i++) {
-				printf("[%03d]: %08x -> %08x\n", i, m->partition[i].hashid, m->partition[i].blockid);
+				printf ("[%03d]: %08x -> %08x\n", i, m->partition[i].hashid, m->partition[i].blockid);
 			}
 		} break;
 		case PARTITION_DATA: {
 			CamelPartitionKeyBlock *k = (CamelPartitionKeyBlock *)buf;
-			printf("Partition data\n");
-			printf("Used: %u\n", k->used);
+			printf ("Partition data\n");
+			printf ("Used: %u\n", k->used);
 		} break;
 		}
 
-		printf("--raw--\n");
+		printf ("--raw--\n");
 
 		len = 1024;
 		p = buf;
 		do {
-			sprintf(line, "%08x:                                                                      ", total);
+			sprintf (line, "%08x:                                                                      ", total);
 			total += 16;
 			o = line+10;
 			a = o+16*2+2;
 			i = 0;
 			while (len && i<16) {
 				c = *p++;
-				*a++ = isprint(c)?c:'.';
+				*a++ = isprint (c)?c:'.';
 				*o++ = hex[(c>>4)&0x0f];
 				*o++ = hex[c&0x0f];
 				i++;
@@ -1178,9 +1191,9 @@ dump_raw(GHashTable *map, gchar *path)
 				len--;
 			}
 			*a = 0;
-			printf("%s\n", line);
+			printf ("%s\n", line);
 		} while (len);
-		printf("\n");
+		printf ("\n");
 	}
 	close (fd);
 }
@@ -1188,9 +1201,9 @@ dump_raw(GHashTable *map, gchar *path)
 
 /* Debug */
 void
-camel_text_index_dump(CamelTextIndex *idx)
+camel_text_index_dump (CamelTextIndex *idx)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 #ifndef DUMP_RAW
 	camel_key_t keyid;
 	gchar *word;
@@ -1200,56 +1213,56 @@ camel_text_index_dump(CamelTextIndex *idx)
 
 	/* Iterate over all names in the file first */
 
-	printf("UID's in index\n");
+	printf ("UID's in index\n");
 
 	keyid = 0;
-	while ((keyid = camel_key_table_next(p->name_index, keyid, &word, &flags, &data))) {
+	while ((keyid = camel_key_table_next (p->name_index, keyid, &word, &flags, &data))) {
 		if ((flags & 1) == 0)
-			printf(" %s\n", word);
+			printf (" %s\n", word);
 		else
-			printf(" %s (deleted)\n", word);
-		g_free(word);
+			printf (" %s (deleted)\n", word);
+		g_free (word);
 	}
 
-	printf("Word's in index\n");
+	printf ("Word's in index\n");
 
 	keyid = 0;
-	while ((keyid = camel_key_table_next(p->word_index, keyid, &word, &flags, &data))) {
+	while ((keyid = camel_key_table_next (p->word_index, keyid, &word, &flags, &data))) {
 		CamelIndexCursor *idc;
 
-		printf("Word: '%s':\n", word);
+		printf ("Word: '%s':\n", word);
 
-		idc = camel_index_find((CamelIndex *)idx, word);
-		while ((name = camel_index_cursor_next(idc))) {
-			printf(" %s", name);
+		idc = camel_index_find ((CamelIndex *)idx, word);
+		while ((name = camel_index_cursor_next (idc))) {
+			printf (" %s", name);
 		}
-		printf("\n");
-		camel_object_unref((CamelObject *)idc);
-		g_free(word);
+		printf ("\n");
+		camel_object_unref (idc);
+		g_free (word);
 	}
 #else
 	/* a more low-level dump routine */
-	GHashTable *block_type = g_hash_table_new(NULL, NULL);
+	GHashTable *block_type = g_hash_table_new (NULL, NULL);
 	camel_block_t id;
 	struct stat st;
 	gint type;
 
-	add_keys(block_type, p->blocks, p->word_index->rootid);
-	add_keys(block_type, p->blocks, p->name_index->rootid);
+	add_keys (block_type, p->blocks, p->word_index->rootid);
+	add_keys (block_type, p->blocks, p->name_index->rootid);
 
-	add_partition(block_type, p->blocks, p->word_hash->rootid);
-	add_partition(block_type, p->blocks, p->name_hash->rootid);
+	add_partition (block_type, p->blocks, p->word_hash->rootid);
+	add_partition (block_type, p->blocks, p->name_hash->rootid);
 
-	dump_raw(block_type, p->blocks->path);
-	g_hash_table_destroy(block_type);
+	dump_raw (block_type, p->blocks->path);
+	g_hash_table_destroy (block_type);
 #endif
 }
 
 /* more debug stuff */
 void
-camel_text_index_validate(CamelTextIndex *idx)
+camel_text_index_validate (CamelTextIndex *idx)
 {
-	struct _CamelTextIndexPrivate *p = CTI_PRIVATE(idx);
+	CamelTextIndexPrivate *p = CAMEL_TEXT_INDEX_GET_PRIVATE (idx);
 	camel_key_t keyid;
 	gchar *word;
 	const gchar *name;
@@ -1261,112 +1274,112 @@ camel_text_index_validate(CamelTextIndex *idx)
 
 	GHashTable *names, *deleted, *words, *keys, *name_word, *word_word;
 
-	names = g_hash_table_new(NULL, NULL);
-	deleted = g_hash_table_new(NULL, NULL);
+	names = g_hash_table_new (NULL, NULL);
+	deleted = g_hash_table_new (NULL, NULL);
 
-	name_word = g_hash_table_new(g_str_hash, g_str_equal);
+	name_word = g_hash_table_new (g_str_hash, g_str_equal);
 
-	words = g_hash_table_new(NULL, NULL);
-	keys = g_hash_table_new(NULL, NULL);
+	words = g_hash_table_new (NULL, NULL);
+	keys = g_hash_table_new (NULL, NULL);
 
-	word_word = g_hash_table_new(g_str_hash, g_str_equal);
+	word_word = g_hash_table_new (g_str_hash, g_str_equal);
 
 	/* Iterate over all names in the file first */
 
-	printf("Checking UID consistency\n");
+	printf ("Checking UID consistency\n");
 
 	keyid = 0;
-	while ((keyid = camel_key_table_next(p->name_index, keyid, &word, &flags, &data))) {
-		if ((oldword = g_hash_table_lookup(names, GINT_TO_POINTER(keyid))) != NULL
-		    || (oldword = g_hash_table_lookup(deleted, GINT_TO_POINTER(keyid))) != NULL) {
-			printf("Warning, name '%s' duplicates key (%x) with name '%s'\n", word, keyid, oldword);
-			g_free(word);
+	while ((keyid = camel_key_table_next (p->name_index, keyid, &word, &flags, &data))) {
+		if ((oldword = g_hash_table_lookup (names, GINT_TO_POINTER (keyid))) != NULL
+		    || (oldword = g_hash_table_lookup (deleted, GINT_TO_POINTER (keyid))) != NULL) {
+			printf ("Warning, name '%s' duplicates key (%x) with name '%s'\n", word, keyid, oldword);
+			g_free (word);
 		} else {
-			g_hash_table_insert(name_word, word, GINT_TO_POINTER (1));
+			g_hash_table_insert (name_word, word, GINT_TO_POINTER (1));
 			if ((flags & 1) == 0) {
-				g_hash_table_insert(names, GINT_TO_POINTER(keyid), word);
+				g_hash_table_insert (names, GINT_TO_POINTER (keyid), word);
 			} else {
-				g_hash_table_insert(deleted, GINT_TO_POINTER(keyid), word);
+				g_hash_table_insert (deleted, GINT_TO_POINTER (keyid), word);
 			}
 		}
 	}
 
-	printf("Checking WORD member consistency\n");
+	printf ("Checking WORD member consistency\n");
 
 	keyid = 0;
-	while ((keyid = camel_key_table_next(p->word_index, keyid, &word, &flags, &data))) {
+	while ((keyid = camel_key_table_next (p->word_index, keyid, &word, &flags, &data))) {
 		CamelIndexCursor *idc;
 		GHashTable *used;
 
 		/* first, check for duplicates of keyid, and data */
-		if ((oldword = g_hash_table_lookup(words, GINT_TO_POINTER(keyid))) != NULL) {
-			printf("Warning, word '%s' duplicates key (%x) with name '%s'\n", word, keyid, oldword);
-			g_free(word);
+		if ((oldword = g_hash_table_lookup (words, GINT_TO_POINTER (keyid))) != NULL) {
+			printf ("Warning, word '%s' duplicates key (%x) with name '%s'\n", word, keyid, oldword);
+			g_free (word);
 			word = oldword;
 		} else {
-			g_hash_table_insert(words, GINT_TO_POINTER(keyid), word);
+			g_hash_table_insert (words, GINT_TO_POINTER (keyid), word);
 		}
 
 		if (data == 0) {
 			/* This may not be an issue if things have been removed over time,
 			   though it is a problem if its a fresh index */
-			printf("Word '%s' has no data associated with it\n", word);
+			printf ("Word '%s' has no data associated with it\n", word);
 		} else {
-			if ((oldword = g_hash_table_lookup(keys, GUINT_TO_POINTER(data))) != NULL) {
-				printf("Warning, word '%s' duplicates data (%x) with name '%s'\n", word, data, oldword);
+			if ((oldword = g_hash_table_lookup (keys, GUINT_TO_POINTER (data))) != NULL) {
+				printf ("Warning, word '%s' duplicates data (%x) with name '%s'\n", word, data, oldword);
 			} else {
-				g_hash_table_insert(keys, GUINT_TO_POINTER(data), word);
+				g_hash_table_insert (keys, GUINT_TO_POINTER (data), word);
 			}
 		}
 
-		if ((oldword = g_hash_table_lookup(word_word, word)) != NULL) {
-			printf("Warning, word '%s' occurs more than once\n", word);
+		if ((oldword = g_hash_table_lookup (word_word, word)) != NULL) {
+			printf ("Warning, word '%s' occurs more than once\n", word);
 		} else {
-			g_hash_table_insert(word_word, word, word);
+			g_hash_table_insert (word_word, word, word);
 		}
 
-		used = g_hash_table_new(g_str_hash, g_str_equal);
+		used = g_hash_table_new (g_str_hash, g_str_equal);
 
-		idc = camel_index_find((CamelIndex *)idx, word);
-		while ((name = camel_index_cursor_next(idc))) {
-			if (g_hash_table_lookup(name_word, name) == NULL) {
-				printf("word '%s' references non-existant name '%s'\n", word, name);
+		idc = camel_index_find ((CamelIndex *)idx, word);
+		while ((name = camel_index_cursor_next (idc))) {
+			if (g_hash_table_lookup (name_word, name) == NULL) {
+				printf ("word '%s' references non-existant name '%s'\n", word, name);
 			}
-			if (g_hash_table_lookup(used, name) != NULL) {
-				printf("word '%s' uses word '%s' more than once\n", word, name);
+			if (g_hash_table_lookup (used, name) != NULL) {
+				printf ("word '%s' uses word '%s' more than once\n", word, name);
 			} else {
-				g_hash_table_insert(used, g_strdup(name), (gpointer)1);
+				g_hash_table_insert (used, g_strdup (name), (gpointer)1);
 			}
 		}
-		camel_object_unref((CamelObject *)idc);
+		camel_object_unref (idc);
 
-		g_hash_table_foreach(used, (GHFunc)g_free, NULL);
-		g_hash_table_destroy(used);
+		g_hash_table_foreach (used, (GHFunc)g_free, NULL);
+		g_hash_table_destroy (used);
 
-		printf("word '%s'\n", word);
+		printf ("word '%s'\n", word);
 
 		while (data) {
-			printf(" data %x ", data);
-			if (camel_key_file_read(p->links, &data, &count, &records) == -1) {
-				printf("Warning, read failed for word '%s', at data '%u'\n", word, data);
+			printf (" data %x ", data);
+			if (camel_key_file_read (p->links, &data, &count, &records) == -1) {
+				printf ("Warning, read failed for word '%s', at data '%u'\n", word, data);
 				data = 0;
 			} else {
-				printf("(%d)\n", (gint)count);
-				g_free(records);
+				printf ("(%d)\n", (gint)count);
+				g_free (records);
 			}
 		}
 	}
 
-	g_hash_table_destroy(names);
-	g_hash_table_destroy(deleted);
-	g_hash_table_destroy(words);
-	g_hash_table_destroy(keys);
+	g_hash_table_destroy (names);
+	g_hash_table_destroy (deleted);
+	g_hash_table_destroy (words);
+	g_hash_table_destroy (keys);
 
-	g_hash_table_foreach(name_word, (GHFunc)g_free, NULL);
-	g_hash_table_destroy(name_word);
+	g_hash_table_foreach (name_word, (GHFunc)g_free, NULL);
+	g_hash_table_destroy (name_word);
 
-	g_hash_table_foreach(word_word, (GHFunc)g_free, NULL);
-	g_hash_table_destroy(word_word);
+	g_hash_table_foreach (word_word, (GHFunc)g_free, NULL);
+	g_hash_table_destroy (word_word);
 }
 
 /* ********************************************************************** */
@@ -1376,17 +1389,17 @@ camel_text_index_validate(CamelTextIndex *idx)
 static CamelIndexNameClass *camel_text_index_name_parent;
 
 #define CIN_CLASS(o) ((CamelTextIndexNameClass *)(((CamelObject *)o)->classfuncs))
-#define CIN_PRIVATE(o) (((CamelTextIndexName *)(o))->priv)
+#define CAMEL_TEXT_INDEX_NAME_GET_PRIVATE(o) (((CamelTextIndexName *)(o))->priv)
 
 static void
-text_index_name_add_word(CamelIndexName *idn, const gchar *word)
+text_index_name_add_word (CamelIndexName *idn, const gchar *word)
 {
-	struct _CamelTextIndexNamePrivate *p = ((CamelTextIndexName *)idn)->priv;
+	CamelTextIndexNamePrivate *p = ((CamelTextIndexName *)idn)->priv;
 
-	if (g_hash_table_lookup(idn->words, word) == NULL) {
-		gchar *w = camel_mempool_strdup(p->pool, word);
+	if (g_hash_table_lookup (idn->words, word) == NULL) {
+		gchar *w = camel_mempool_strdup (p->pool, word);
 
-		g_hash_table_insert(idn->words, w, w);
+		g_hash_table_insert (idn->words, w, w);
 	}
 }
 
@@ -1395,7 +1408,7 @@ text_index_name_add_word(CamelIndexName *idn, const gchar *word)
    Used to clean up utf8 before it gets further */
 
 static inline guint32
-camel_utf8_next(const guchar **ptr, const guchar *ptrend)
+camel_utf8_next (const guchar **ptr, const guchar *ptrend)
 {
 	register guchar *p = (guchar *)*ptr;
 	register guint c;
@@ -1455,9 +1468,9 @@ camel_utf8_next(const guchar **ptr, const guchar *ptrend)
 }
 
 static gsize
-text_index_name_add_buffer(CamelIndexName *idn, const gchar *buffer, gsize len)
+text_index_name_add_buffer (CamelIndexName *idn, const gchar *buffer, gsize len)
 {
-	CamelTextIndexNamePrivate *p = CIN_PRIVATE(idn);
+	CamelTextIndexNamePrivate *p = CAMEL_TEXT_INDEX_NAME_GET_PRIVATE (idn);
 	const guchar *ptr, *ptrend;
 	guint32 c;
 	gchar utf8[8];
@@ -1465,24 +1478,24 @@ text_index_name_add_buffer(CamelIndexName *idn, const gchar *buffer, gsize len)
 
 	if (buffer == NULL) {
 		if (p->buffer->len) {
-			camel_index_name_add_word(idn, p->buffer->str);
-			g_string_truncate(p->buffer, 0);
+			camel_index_name_add_word (idn, p->buffer->str);
+			g_string_truncate (p->buffer, 0);
 		}
 		return 0;
 	}
 
 	ptr = (const guchar *) buffer;
 	ptrend = (const guchar *) buffer+len;
-	while ((c = camel_utf8_next(&ptr, ptrend))) {
-		if (g_unichar_isalnum(c)) {
-			c = g_unichar_tolower(c);
-			utf8len = g_unichar_to_utf8(c, utf8);
+	while ((c = camel_utf8_next (&ptr, ptrend))) {
+		if (g_unichar_isalnum (c)) {
+			c = g_unichar_tolower (c);
+			utf8len = g_unichar_to_utf8 (c, utf8);
 			utf8[utf8len] = 0;
-			g_string_append(p->buffer, utf8);
+			g_string_append (p->buffer, utf8);
 		} else {
 			if (p->buffer->len > 0 && p->buffer->len <= CAMEL_TEXT_INDEX_MAX_WORDLEN) {
-				text_index_name_add_word(idn, p->buffer->str);
-				/*camel_index_name_add_word(idn, p->buffer->str);*/
+				text_index_name_add_word (idn, p->buffer->str);
+				/*camel_index_name_add_word (idn, p->buffer->str);*/
 			}
 
 			g_string_truncate (p->buffer, 0);
@@ -1493,48 +1506,48 @@ text_index_name_add_buffer(CamelIndexName *idn, const gchar *buffer, gsize len)
 }
 
 static void
-camel_text_index_name_class_init(CamelTextIndexNameClass *klass)
+camel_text_index_name_class_init (CamelTextIndexNameClass *klass)
 {
 	CamelIndexNameClass *nklass = (CamelIndexNameClass *)klass;
 
-	camel_text_index_name_parent = CAMEL_INDEX_NAME_CLASS(camel_type_get_global_classfuncs(camel_index_name_get_type()));
+	camel_text_index_name_parent = CAMEL_INDEX_NAME_CLASS (camel_type_get_global_classfuncs (camel_index_name_get_type ()));
 
 	nklass->add_word = text_index_name_add_word;
 	nklass->add_buffer = text_index_name_add_buffer;
 }
 
 static void
-camel_text_index_name_init(CamelTextIndexName *idn)
+camel_text_index_name_init (CamelTextIndexName *idn)
 {
 	CamelTextIndexNamePrivate *p;
 
-	idn->parent.words = g_hash_table_new(g_str_hash, g_str_equal);
+	idn->parent.words = g_hash_table_new (g_str_hash, g_str_equal);
 
-	p = idn->priv = g_malloc0(sizeof(*idn->priv));
-	p->buffer = g_string_new("");
-	p->pool = camel_mempool_new(256, 128, CAMEL_MEMPOOL_ALIGN_BYTE);
+	p = idn->priv = g_malloc0(sizeof (*idn->priv));
+	p->buffer = g_string_new ("");
+	p->pool = camel_mempool_new (256, 128, CAMEL_MEMPOOL_ALIGN_BYTE);
 }
 
 static void
-camel_text_index_name_finalize(CamelTextIndexName *idn)
+camel_text_index_name_finalize (CamelTextIndexName *idn)
 {
-	CamelTextIndexNamePrivate *p = CIN_PRIVATE(idn);
+	CamelTextIndexNamePrivate *p = CAMEL_TEXT_INDEX_NAME_GET_PRIVATE (idn);
 
-	g_hash_table_destroy(idn->parent.words);
+	g_hash_table_destroy (idn->parent.words);
 
-	g_string_free(p->buffer, TRUE);
-	camel_mempool_destroy(p->pool);
+	g_string_free (p->buffer, TRUE);
+	camel_mempool_destroy (p->pool);
 
-	g_free(p);
+	g_free (p);
 }
 
 CamelType
-camel_text_index_name_get_type(void)
+camel_text_index_name_get_type (void)
 {
 	static CamelType type = CAMEL_INVALID_TYPE;
 
 	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register(camel_index_name_get_type(), "CamelTextIndexName",
+		type = camel_type_register (camel_index_name_get_type (), "CamelTextIndexName",
 					   sizeof (CamelTextIndexName),
 					   sizeof (CamelTextIndexNameClass),
 					   (CamelObjectClassInitFunc) camel_text_index_name_class_init,
@@ -1547,15 +1560,14 @@ camel_text_index_name_get_type(void)
 }
 
 CamelTextIndexName *
-camel_text_index_name_new(CamelTextIndex *idx, const gchar *name, camel_key_t nameid)
+camel_text_index_name_new (CamelTextIndex *idx, const gchar *name, camel_key_t nameid)
 {
-	CamelTextIndexName *idn = (CamelTextIndexName *)camel_object_new(camel_text_index_name_get_type());
+	CamelTextIndexName *idn = (CamelTextIndexName *)camel_object_new (camel_text_index_name_get_type ());
 	CamelIndexName *cin = &idn->parent;
-	CamelTextIndexNamePrivate *p = CIN_PRIVATE(idn);
+	CamelTextIndexNamePrivate *p = CAMEL_TEXT_INDEX_NAME_GET_PRIVATE (idn);
 
-	cin->index = (CamelIndex *)idx;
-	camel_object_ref((CamelObject *)idx);
-	cin->name = camel_mempool_strdup(p->pool, name);
+	cin->index = camel_object_ref (idx);
+	cin->name = camel_mempool_strdup (p->pool, name);
 	p->nameid = nameid;
 
 	return idn;
@@ -1568,33 +1580,35 @@ camel_text_index_name_new(CamelTextIndex *idx, const gchar *name, camel_key_t na
 static CamelIndexCursorClass *camel_text_index_cursor_parent;
 
 #define CIC_CLASS(o) ((CamelTextIndexCursorClass *)(((CamelObject *)o)->classfuncs))
-#define CIC_PRIVATE(o) (((CamelTextIndexCursor *)(o))->priv)
+#define CAMEL_TEXT_INDEX_CURSOR_GET_PRIVATE(o) (((CamelTextIndexCursor *)(o))->priv)
 
 static const gchar *
-text_index_cursor_next(CamelIndexCursor *idc)
+text_index_cursor_next (CamelIndexCursor *idc)
 {
-	struct _CamelTextIndexCursorPrivate *p = CIC_PRIVATE(idc);
-	struct _CamelTextIndexPrivate *tip = CTI_PRIVATE(idc->index);
+	CamelTextIndexCursorPrivate *p = CAMEL_TEXT_INDEX_CURSOR_GET_PRIVATE (idc);
+	CamelTextIndexPrivate *tip = CAMEL_TEXT_INDEX_GET_PRIVATE (idc->index);
 	guint flags;
 
-	c(printf("Going to next cursor for word with data '%08x' next %08x\n", p->first, p->next));
+	c (printf ("Going to next cursor for word with data '%08x' next %08x\n", p->first, p->next));
 
 	do {
 		while (p->record_index >= p->record_count) {
-			g_free(p->records);
+			g_free (p->records);
 			p->records = NULL;
 			p->record_index = 0;
 			p->record_count = 0;
 			if (p->next == 0)
 				return NULL;
-			if (camel_key_file_read(tip->links, &p->next, &p->record_count, &p->records) == -1)
+			if (camel_key_file_read (tip->links, &p->next, &p->record_count, &p->records) == -1)
 				return NULL;
 		}
 
-		g_free(p->current);
-		camel_key_table_lookup(tip->name_index, p->records[p->record_index], &p->current, &flags);
+		g_free (p->current);
+		camel_key_table_lookup (
+			tip->name_index, p->records[p->record_index],
+			&p->current, &flags);
 		if (flags & 1) {
-			g_free(p->current);
+			g_free (p->current);
 			p->current = NULL;
 		}
 		p->record_index++;
@@ -1604,13 +1618,13 @@ text_index_cursor_next(CamelIndexCursor *idc)
 }
 
 static void
-text_index_cursor_reset(CamelIndexCursor *idc)
+text_index_cursor_reset (CamelIndexCursor *idc)
 {
-	struct _CamelTextIndexCursorPrivate *p = CIC_PRIVATE(idc);
+	CamelTextIndexCursorPrivate *p = CAMEL_TEXT_INDEX_CURSOR_GET_PRIVATE (idc);
 
-	g_free(p->records);
+	g_free (p->records);
 	p->records = NULL;
-	g_free(p->current);
+	g_free (p->current);
 	p->current = NULL;
 	p->record_count = 0;
 	p->record_index = 0;
@@ -1618,39 +1632,39 @@ text_index_cursor_reset(CamelIndexCursor *idc)
 }
 
 static void
-camel_text_index_cursor_class_init(CamelTextIndexCursorClass *klass)
+camel_text_index_cursor_class_init (CamelTextIndexCursorClass *klass)
 {
 	CamelIndexCursorClass *cklass = (CamelIndexCursorClass *)klass;
 
-	camel_text_index_cursor_parent = CAMEL_INDEX_CURSOR_CLASS(camel_type_get_global_classfuncs(camel_index_cursor_get_type()));
+	camel_text_index_cursor_parent = CAMEL_INDEX_CURSOR_CLASS (camel_type_get_global_classfuncs (camel_index_cursor_get_type ()));
 
 	cklass->next = text_index_cursor_next;
 	cklass->reset = text_index_cursor_reset;
 }
 
 static void
-camel_text_index_cursor_init(CamelTextIndexCursor *idc)
+camel_text_index_cursor_init (CamelTextIndexCursor *idc)
 {
-	CIC_PRIVATE(idc) = g_malloc0(sizeof(struct _CamelTextIndexCursorPrivate));
+	CAMEL_TEXT_INDEX_CURSOR_GET_PRIVATE (idc) = g_malloc0(sizeof (CamelTextIndexCursorPrivate));
 }
 
 static void
-camel_text_index_cursor_finalize(CamelTextIndexCursor *idc)
+camel_text_index_cursor_finalize (CamelTextIndexCursor *idc)
 {
-	struct _CamelTextIndexCursorPrivate *p = CIC_PRIVATE(idc);
+	CamelTextIndexCursorPrivate *p = CAMEL_TEXT_INDEX_CURSOR_GET_PRIVATE (idc);
 
-	g_free(p->records);
-	g_free(p->current);
-	g_free(p);
+	g_free (p->records);
+	g_free (p->current);
+	g_free (p);
 }
 
 CamelType
-camel_text_index_cursor_get_type(void)
+camel_text_index_cursor_get_type (void)
 {
 	static CamelType type = CAMEL_INVALID_TYPE;
 
 	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register(camel_index_cursor_get_type(), "CamelTextIndexCursor",
+		type = camel_type_register (camel_index_cursor_get_type (), "CamelTextIndexCursor",
 					   sizeof (CamelTextIndexCursor),
 					   sizeof (CamelTextIndexCursorClass),
 					   (CamelObjectClassInitFunc) camel_text_index_cursor_class_init,
@@ -1663,14 +1677,13 @@ camel_text_index_cursor_get_type(void)
 }
 
 CamelTextIndexCursor *
-camel_text_index_cursor_new(CamelTextIndex *idx, camel_block_t data)
+camel_text_index_cursor_new (CamelTextIndex *idx, camel_block_t data)
 {
-	CamelTextIndexCursor *idc = (CamelTextIndexCursor *)camel_object_new(camel_text_index_cursor_get_type());
+	CamelTextIndexCursor *idc = (CamelTextIndexCursor *)camel_object_new (camel_text_index_cursor_get_type ());
 	CamelIndexCursor *cic = &idc->parent;
-	struct _CamelTextIndexCursorPrivate *p = CIC_PRIVATE(idc);
+	CamelTextIndexCursorPrivate *p = CAMEL_TEXT_INDEX_CURSOR_GET_PRIVATE (idc);
 
-	cic->index = (CamelIndex *)idx;
-	camel_object_ref((CamelObject *)idx);
+	cic->index = camel_object_ref (idx);
 	p->first = data;
 	p->next = data;
 	p->record_count = 0;
@@ -1686,23 +1699,23 @@ camel_text_index_cursor_new(CamelTextIndex *idx, camel_block_t data)
 static CamelIndexCursorClass *camel_text_index_key_cursor_parent;
 
 #define CIKC_CLASS(o) ((CamelTextIndexKeyCursorClass *)(((CamelObject *)o)->classfuncs))
-#define CIKC_PRIVATE(o) (((CamelTextIndexKeyCursor *)(o))->priv)
+#define CAMEL_TEXT_INDEX_KEY_CURSOR_GET_PRIVATE(o) (((CamelTextIndexKeyCursor *)(o))->priv)
 
 static const gchar *
-text_index_key_cursor_next(CamelIndexCursor *idc)
+text_index_key_cursor_next (CamelIndexCursor *idc)
 {
-	struct _CamelTextIndexKeyCursorPrivate *p = CIKC_PRIVATE(idc);
+	CamelTextIndexKeyCursorPrivate *p = CAMEL_TEXT_INDEX_KEY_CURSOR_GET_PRIVATE (idc);
 
-	c(printf("Going to next cursor for keyid %08x\n", p->keyid));
+	c (printf ("Going to next cursor for keyid %08x\n", p->keyid));
 
-	g_free(p->current);
+	g_free (p->current);
 	p->current = NULL;
 
-	while ((p->keyid = camel_key_table_next(p->table, p->keyid, &p->current, &p->flags, &p->data))) {
+	while ((p->keyid = camel_key_table_next (p->table, p->keyid, &p->current, &p->flags, &p->data))) {
 		if ((p->flags & 1) == 0) {
 			return p->current;
 		} else {
-			g_free(p->current);
+			g_free (p->current);
 			p->current = NULL;
 		}
 	}
@@ -1711,34 +1724,34 @@ text_index_key_cursor_next(CamelIndexCursor *idc)
 }
 
 static void
-text_index_key_cursor_reset(CamelIndexCursor *idc)
+text_index_key_cursor_reset (CamelIndexCursor *idc)
 {
-	struct _CamelTextIndexKeyCursorPrivate *p = CIKC_PRIVATE(idc);
+	CamelTextIndexKeyCursorPrivate *p = CAMEL_TEXT_INDEX_KEY_CURSOR_GET_PRIVATE (idc);
 
 	p->keyid = 0;
 	p->flags = 0;
 	p->data = 0;
-	g_free(p->current);
+	g_free (p->current);
 	p->current = NULL;
 }
 
 static void
-camel_text_index_key_cursor_class_init(CamelTextIndexKeyCursorClass *klass)
+camel_text_index_key_cursor_class_init (CamelTextIndexKeyCursorClass *klass)
 {
 	CamelIndexCursorClass *cklass = (CamelIndexCursorClass *)klass;
 
-	camel_text_index_key_cursor_parent = CAMEL_INDEX_CURSOR_CLASS(camel_type_get_global_classfuncs(camel_index_cursor_get_type()));
+	camel_text_index_key_cursor_parent = CAMEL_INDEX_CURSOR_CLASS (camel_type_get_global_classfuncs (camel_index_cursor_get_type ()));
 
 	cklass->next = text_index_key_cursor_next;
 	cklass->reset = text_index_key_cursor_reset;
 }
 
 static void
-camel_text_index_key_cursor_init(CamelTextIndexKeyCursor *idc)
+camel_text_index_key_cursor_init (CamelTextIndexKeyCursor *idc)
 {
-	struct _CamelTextIndexKeyCursorPrivate *p;
+	CamelTextIndexKeyCursorPrivate *p;
 
-	p = idc->priv = g_malloc0(sizeof(struct _CamelTextIndexKeyCursorPrivate));
+	p = idc->priv = g_malloc0(sizeof (CamelTextIndexKeyCursorPrivate));
 	p->keyid = 0;
 	p->flags = 0;
 	p->data = 0;
@@ -1746,23 +1759,23 @@ camel_text_index_key_cursor_init(CamelTextIndexKeyCursor *idc)
 }
 
 static void
-camel_text_index_key_cursor_finalize(CamelTextIndexKeyCursor *idc)
+camel_text_index_key_cursor_finalize (CamelTextIndexKeyCursor *idc)
 {
-	struct _CamelTextIndexKeyCursorPrivate *p = CIKC_PRIVATE(idc);
+	CamelTextIndexKeyCursorPrivate *p = CAMEL_TEXT_INDEX_KEY_CURSOR_GET_PRIVATE (idc);
 
-	g_free(p->current);
+	g_free (p->current);
 	if (p->table)
-		camel_object_unref((CamelObject *)p->table);
-	g_free(p);
+		camel_object_unref (p->table);
+	g_free (p);
 }
 
 CamelType
-camel_text_index_key_cursor_get_type(void)
+camel_text_index_key_cursor_get_type (void)
 {
 	static CamelType type = CAMEL_INVALID_TYPE;
 
 	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register(camel_index_cursor_get_type(), "CamelTextIndexKeyCursor",
+		type = camel_type_register (camel_index_cursor_get_type (), "CamelTextIndexKeyCursor",
 					   sizeof (CamelTextIndexKeyCursor),
 					   sizeof (CamelTextIndexKeyCursorClass),
 					   (CamelObjectClassInitFunc) camel_text_index_key_cursor_class_init,
@@ -1775,16 +1788,14 @@ camel_text_index_key_cursor_get_type(void)
 }
 
 CamelTextIndexKeyCursor *
-camel_text_index_key_cursor_new(CamelTextIndex *idx, CamelKeyTable *table)
+camel_text_index_key_cursor_new (CamelTextIndex *idx, CamelKeyTable *table)
 {
-	CamelTextIndexKeyCursor *idc = (CamelTextIndexKeyCursor *)camel_object_new(camel_text_index_key_cursor_get_type());
+	CamelTextIndexKeyCursor *idc = (CamelTextIndexKeyCursor *)camel_object_new (camel_text_index_key_cursor_get_type ());
 	CamelIndexCursor *cic = &idc->parent;
-	struct _CamelTextIndexKeyCursorPrivate *p = CIKC_PRIVATE(idc);
+	CamelTextIndexKeyCursorPrivate *p = CAMEL_TEXT_INDEX_KEY_CURSOR_GET_PRIVATE (idc);
 
-	cic->index = (CamelIndex *)idx;
-	camel_object_ref((CamelObject *)idx);
-	p->table = table;
-	camel_object_ref((CamelObject *)table);
+	cic->index = camel_object_ref (idx);
+	p->table = camel_object_ref (table);
 
 	return idc;
 }
@@ -1810,7 +1821,7 @@ gchar wordbuffer[] = "This is a buffer of multiple words.  Some of the words are
 " with,with:with;with-with'with\"'\"various punctuation as well.  So much for those Words. and 10"
 " numbers in a row too 1,2,3,4,5,6,7,8,9,10!  Yay!.";
 
-gint main(gint argc, gchar **argv)
+gint main (gint argc, gchar **argv)
 {
 #if 0
 	CamelBlockFile *bs;
@@ -1829,15 +1840,15 @@ gint main(gint argc, gchar **argv)
 	const gchar *word;
 	gint i;
 
-	printf("Camel text index tester!\n");
+	printf ("Camel text index tester!\n");
 
-	g_thread_init(NULL);
-	camel_init(NULL, 0);
+	g_thread_init (NULL);
+	camel_init (NULL, 0);
 
-	idx = (CamelIndex *)camel_text_index_new("textindex", O_CREAT|O_RDWR|O_TRUNC);
+	idx = (CamelIndex *)camel_text_index_new ("textindex", O_CREAT|O_RDWR|O_TRUNC);
 
 #if 1
-	camel_index_compress(idx);
+	camel_index_compress (idx);
 
 	return 0;
 #endif
@@ -1845,115 +1856,115 @@ gint main(gint argc, gchar **argv)
 	for (i=0;i<100;i++) {
 		gchar name[16];
 
-		sprintf(name, "%d", i);
-		printf("Adding words to name '%s'\n", name);
-		idn = camel_index_add_name(idx, name);
-		camel_index_name_add_buffer(idn, wordbuffer, sizeof(wordbuffer)-1);
-		camel_index_write_name(idx, idn);
-		camel_object_unref((CamelObject *)idn);
+		sprintf (name, "%d", i);
+		printf ("Adding words to name '%s'\n", name);
+		idn = camel_index_add_name (idx, name);
+		camel_index_name_add_buffer (idn, wordbuffer, sizeof (wordbuffer)-1);
+		camel_index_write_name (idx, idn);
+		camel_object_unref (idn);
 	}
 
-	printf("Looking up which names contain word 'word'\n");
-	idc = camel_index_find(idx, "words");
-	while ((word = camel_index_cursor_next(idc)) != NULL) {
-		printf(" name is '%s'\n", word);
+	printf ("Looking up which names contain word 'word'\n");
+	idc = camel_index_find (idx, "words");
+	while ((word = camel_index_cursor_next (idc)) != NULL) {
+		printf (" name is '%s'\n", word);
 	}
-	camel_object_unref((CamelObject *)idc);
-	printf("done.\n");
+	camel_object_unref (idc);
+	printf ("done.\n");
 
-	printf("Looking up which names contain word 'truncate'\n");
-	idc = camel_index_find(idx, "truncate");
-	while ((word = camel_index_cursor_next(idc)) != NULL) {
-		printf(" name is '%s'\n", word);
+	printf ("Looking up which names contain word 'truncate'\n");
+	idc = camel_index_find (idx, "truncate");
+	while ((word = camel_index_cursor_next (idc)) != NULL) {
+		printf (" name is '%s'\n", word);
 	}
-	camel_object_unref((CamelObject *)idc);
-	printf("done.\n");
+	camel_object_unref (idc);
+	printf ("done.\n");
 
-	camel_index_sync(idx);
-	camel_object_unref((CamelObject *)idx);
+	camel_index_sync (idx);
+	camel_object_unref (idx);
 
 #if 0
-	bs = camel_block_file_new("blocks", "TESTINDX", CAMEL_BLOCK_SIZE);
+	bs = camel_block_file_new ("blocks", "TESTINDX", CAMEL_BLOCK_SIZE);
 
 	root = (struct _CamelIndexRoot *)bs->root;
 	if (root->word_root == 0) {
-		keyroot = camel_block_file_new_block(bs);
+		keyroot = camel_block_file_new_block (bs);
 		root->word_root = keyroot->id;
-		camel_block_file_touch_block(bs, bs->root_block);
+		camel_block_file_touch_block (bs, bs->root_block);
 	}
 	if (root->word_hash_root == 0) {
-		partroot = camel_block_file_new_block(bs);
+		partroot = camel_block_file_new_block (bs);
 		root->word_hash_root = partroot->id;
-		camel_block_file_touch_block(bs, bs->root_block);
+		camel_block_file_touch_block (bs, bs->root_block);
 	}
 
-	ki = camel_key_table_new(bs, root->word_root);
-	cpi = camel_partition_table_new(bs, root->word_hash_root);
+	ki = camel_key_table_new (bs, root->word_root);
+	cpi = camel_partition_table_new (bs, root->word_hash_root);
 
-	fp = fopen("/usr/dict/words", "r");
+	fp = fopen ("/usr/dict/words", "r");
 	if (fp == NULL) {
-		perror("fopen");
+		perror ("fopen");
 		return 1;
 	}
 
-	while (fgets(line, sizeof(line), fp) != NULL) {
-		line[strlen(line)-1] = 0;
+	while (fgets (line, sizeof (line), fp) != NULL) {
+		line[strlen (line)-1] = 0;
 
 		/* see if its already there */
-		keyid = camel_partition_table_lookup(cpi, line);
+		keyid = camel_partition_table_lookup (cpi, line);
 		if (keyid == 0) {
-			m(printf("Adding word '%s' %d\n", line, index));
+			m (printf ("Adding word '%s' %d\n", line, index));
 
-			keyid = camel_key_table_add(ki, line, index, 0);
-			m(printf(" key = %08x\n", keyid));
+			keyid = camel_key_table_add (ki, line, index, 0);
+			m (printf (" key = %08x\n", keyid));
 
-			camel_partition_table_add(cpi, line, keyid);
+			camel_partition_table_add (cpi, line, keyid);
 
-			m(printf("Lookup word '%s'\n", line));
-			keyid = camel_partition_table_lookup(cpi, line);
-			m(printf(" key = %08x\n", keyid));
+			m (printf ("Lookup word '%s'\n", line));
+			keyid = camel_partition_table_lookup (cpi, line);
+			m (printf (" key = %08x\n", keyid));
 		}
 
-		m(printf("Lookup key %08x\n", keyid));
+		m (printf ("Lookup key %08x\n", keyid));
 
-		camel_key_table_set_flags(ki, keyid, index, 1);
+		camel_key_table_set_flags (ki, keyid, index, 1);
 
-		data = camel_key_table_lookup(ki, keyid, &key, &flags);
-		m(printf(" word = '%s' %d %04x\n", key, data, flags));
+		data = camel_key_table_lookup (ki, keyid, &key, &flags);
+		m (printf (" word = '%s' %d %04x\n", key, data, flags));
 
-		g_assert(data == index && strcmp(key, line) == 0);
+		g_assert (data == index && strcmp (key, line) == 0);
 
-		g_free(key);
+		g_free (key);
 
 		index++;
 	}
 
-	printf("Scanning again\n");
-	fseek(fp, SEEK_SET, 0);
+	printf ("Scanning again\n");
+	fseek (fp, SEEK_SET, 0);
 	index = 0;
-	while (fgets(line, sizeof(line), fp) != NULL) {
-		line[strlen(line)-1] = 0;
-		m(printf("Lookup word '%s' %d\n", line, index));
-		keyid = camel_partition_table_lookup(cpi, line);
-		m(printf(" key = %08d\n", keyid));
+	while (fgets (line, sizeof (line), fp) != NULL) {
+		line[strlen (line)-1] = 0;
+		m (printf ("Lookup word '%s' %d\n", line, index));
+		keyid = camel_partition_table_lookup (cpi, line);
+		m (printf (" key = %08d\n", keyid));
 
-		m(printf("Lookup key %08x\n", keyid));
-		data = camel_key_table_lookup(ki, keyid, &key, &flags);
-		m(printf(" word = '%s' %d\n", key, data));
+		m (printf ("Lookup key %08x\n", keyid));
+		data = camel_key_table_lookup (ki, keyid, &key, &flags);
+		m (printf (" word = '%s' %d\n", key, data));
 
-		g_assert(data == index && strcmp(key, line) == 0);
+		g_assert (data == index && strcmp (key, line) == 0);
 
-		g_free(key);
+		g_free (key);
 
 		index++;
 	}
 	fclose (fp);
 
-	printf("Freeing partition index\n");
-	camel_partition_table_free(cpi);
+	printf ("Freeing partition index\n");
+	camel_partition_table_free (cpi);
 
-	printf("Syncing block file\n");
-	camel_block_file_sync(bs);
+	printf ("Syncing block file\n");
+	camel_block_file_sync (bs);
 #endif
 	return 0;
 }
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c
index 66abecc..4d10b7c 100644
--- a/camel/camel-vee-folder.c
+++ b/camel/camel-vee-folder.c
@@ -26,7 +26,6 @@
 
 #include <string.h>
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 
 #include "camel-db.h"
@@ -45,40 +44,40 @@
 #include "camel-vtrash-folder.h"
 
 #define d(x)
-#define dd(x) (camel_debug("vfolder")?(x):0)
+#define dd(x) (camel_debug ("vfolder")?(x):0)
 
 #define _PRIVATE(o) (((CamelVeeFolder *)(o))->priv)
 
 #if 0
-static void vee_refresh_info(CamelFolder *folder, CamelException *ex);
+static void vee_refresh_info (CamelFolder *folder, CamelException *ex);
 
 static void vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);
 static void vee_expunge (CamelFolder *folder, CamelException *ex);
 
-static void vee_freeze(CamelFolder *folder);
-static void vee_thaw(CamelFolder *folder);
+static void vee_freeze (CamelFolder *folder);
+static void vee_thaw (CamelFolder *folder);
 
 static CamelMimeMessage *vee_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
-static void vee_append_message(CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex);
-static void vee_transfer_messages_to(CamelFolder *source, GPtrArray *uids, CamelFolder *dest, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex);
+static void vee_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex);
+static void vee_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex);
 
-static guint32 vee_count_by_expression(CamelFolder *folder, const gchar *expression, CamelException *ex);
-static GPtrArray *vee_search_by_expression(CamelFolder *folder, const gchar *expression, CamelException *ex);
-static GPtrArray *vee_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex);
+static guint32 vee_count_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex);
+static GPtrArray *vee_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex);
+static GPtrArray *vee_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex);
 
-static void vee_rename(CamelFolder *folder, const gchar *new);
+static void vee_rename (CamelFolder *folder, const gchar *new);
 #endif
 
 static void camel_vee_folder_class_init (CamelVeeFolderClass *klass);
 static void camel_vee_folder_init       (CamelVeeFolder *obj);
 static void camel_vee_folder_finalize   (CamelObject *obj);
 
-static gint vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex);
-static void vee_folder_remove_folder(CamelVeeFolder *vf, CamelFolder *source);
+static gint vee_rebuild_folder (CamelVeeFolder *vf, CamelFolder *source, CamelException *ex);
+static void vee_folder_remove_folder (CamelVeeFolder *vf, CamelFolder *source);
 
-static void folder_changed(CamelFolder *sub, CamelFolderChangeInfo *changes, CamelVeeFolder *vf);
-static void subfolder_deleted(CamelFolder *f, gpointer event_data, CamelVeeFolder *vf);
-static void folder_renamed(CamelFolder *f, const gchar *old, CamelVeeFolder *vf);
+static void folder_changed (CamelFolder *sub, CamelFolderChangeInfo *changes, CamelVeeFolder *vf);
+static void subfolder_deleted (CamelFolder *f, gpointer event_data, CamelVeeFolder *vf);
+static void folder_renamed (CamelFolder *f, const gchar *old, CamelVeeFolder *vf);
 
 static CamelFolderClass *camel_vee_folder_parent;
 
@@ -106,11 +105,11 @@ camel_vee_folder_construct (CamelVeeFolder *vf, CamelStore *parent_store, const
 	CamelFolder *folder = (CamelFolder *)vf;
 
 	vf->flags = flags;
-	camel_folder_construct(folder, parent_store, full, name);
+	camel_folder_construct (folder, parent_store, full, name);
 
-	folder->summary = camel_vee_summary_new(folder);
+	folder->summary = camel_vee_summary_new (folder);
 
-	if (CAMEL_IS_VEE_STORE(parent_store))
+	if (CAMEL_IS_VEE_STORE (parent_store))
 		vf->parent_vee_store = (CamelVeeStore *)parent_store;
 }
 
@@ -125,32 +124,32 @@ camel_vee_folder_construct (CamelVeeFolder *vf, CamelStore *parent_store, const
  * Returns: A new CamelVeeFolder widget.
  **/
 CamelFolder *
-camel_vee_folder_new(CamelStore *parent_store, const gchar *full, guint32 flags)
+camel_vee_folder_new (CamelStore *parent_store, const gchar *full, guint32 flags)
 {
 	CamelVeeFolder *vf;
 	gchar *tmp;
 
-	if (CAMEL_IS_VEE_STORE(parent_store) && strcmp(full, CAMEL_UNMATCHED_NAME) == 0) {
+	if (CAMEL_IS_VEE_STORE (parent_store) && strcmp (full, CAMEL_UNMATCHED_NAME) == 0) {
 		vf = ((CamelVeeStore *)parent_store)->folder_unmatched;
-		camel_object_ref(vf);
+		camel_object_ref (vf);
 	} else {
-		const gchar *name = strrchr(full, '/');
+		const gchar *name = strrchr (full, '/');
 
 		if (name == NULL)
 			name = full;
 		else
 			name++;
-		vf = (CamelVeeFolder *)camel_object_new(camel_vee_folder_get_type());
-		camel_vee_folder_construct(vf, parent_store, full, name, flags);
+		vf = (CamelVeeFolder *)camel_object_new (camel_vee_folder_get_type ());
+		camel_vee_folder_construct (vf, parent_store, full, name, flags);
 	}
 
-	d(printf("returning folder %s %p, count = %d\n", full, vf, camel_folder_get_message_count((CamelFolder *)vf)));
+	d (printf ("returning folder %s %p, count = %d\n", full, vf, camel_folder_get_message_count ((CamelFolder *)vf)));
 
 	if (vf) {
-		tmp = g_strdup_printf("%s/%s.cmeta", ((CamelService *)parent_store)->url->path, full);
-		camel_object_set(vf, NULL, CAMEL_OBJECT_STATE_FILE, tmp, NULL);
-		g_free(tmp);
-		if (camel_object_state_read(vf) == -1) {
+		tmp = g_strdup_printf ("%s/%s.cmeta", ((CamelService *)parent_store)->url->path, full);
+		camel_object_set (vf, NULL, CAMEL_OBJECT_STATE_FILE, tmp, NULL);
+		g_free (tmp);
+		if (camel_object_state_read (vf) == -1) {
 			/* setup defaults: we have none currently */
 		}
 	}
@@ -158,9 +157,9 @@ camel_vee_folder_new(CamelStore *parent_store, const gchar *full, guint32 flags)
 }
 
 void
-camel_vee_folder_set_expression(CamelVeeFolder *vf, const gchar *query)
+camel_vee_folder_set_expression (CamelVeeFolder *vf, const gchar *query)
 {
-	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->set_expression(vf, query);
+	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->set_expression (vf, query);
 }
 
 /**
@@ -171,55 +170,55 @@ camel_vee_folder_set_expression(CamelVeeFolder *vf, const gchar *query)
  * Adds @sub as a source folder to @vf.
  **/
 void
-camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
+camel_vee_folder_add_folder (CamelVeeFolder *vf, CamelFolder *sub)
 {
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
 	gint i;
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 
 	if (vf == (CamelVeeFolder *)sub) {
-		g_warning("Adding a virtual folder to itself as source, ignored");
+		g_warning ("Adding a virtual folder to itself as source, ignored");
 		return;
 	}
 
-	CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
 
 	/* for normal vfolders we want only unique ones, for unmatched we want them all recorded */
-	if (g_list_find(p->folders, sub) == NULL) {
-		camel_object_ref((CamelObject *)sub);
-		p->folders = g_list_append(p->folders, sub);
+	if (g_list_find (p->folders, sub) == NULL) {
+		p->folders = g_list_append (
+			p->folders, camel_object_ref (sub));
 
-		CAMEL_FOLDER_LOCK(vf, change_lock);
+		CAMEL_FOLDER_LOCK (vf, change_lock);
 
 		/* update the freeze state of 'sub' to match our freeze state */
 		for (i = 0; i < ((CamelFolder *)vf)->priv->frozen; i++)
-			camel_folder_freeze(sub);
+			camel_folder_freeze (sub);
 
-		CAMEL_FOLDER_UNLOCK(vf, change_lock);
+		CAMEL_FOLDER_UNLOCK (vf, change_lock);
 	}
-	if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER(sub) && folder_unmatched != NULL) {
-		struct _CamelVeeFolderPrivate *up = _PRIVATE(folder_unmatched);
-		camel_object_ref((CamelObject *)sub);
-		up->folders = g_list_append(up->folders, sub);
+	if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER (sub) && folder_unmatched != NULL) {
+		struct _CamelVeeFolderPrivate *up = _PRIVATE (folder_unmatched);
+		up->folders = g_list_append (
+			up->folders, camel_object_ref (sub));
 
-		CAMEL_FOLDER_LOCK(folder_unmatched, change_lock);
+		CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
 
 		/* update the freeze state of 'sub' to match Unmatched's freeze state */
 		for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
-			camel_folder_freeze(sub);
+			camel_folder_freeze (sub);
 
-		CAMEL_FOLDER_UNLOCK(folder_unmatched, change_lock);
+		CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
 	}
 
-	CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 
-	d(printf("camel_vee_folder_add_folder(%s, %s)\n", ((CamelFolder *)vf)->full_name, sub->full_name));
+	d (printf ("camel_vee_folder_add_folder (%s, %s)\n", ((CamelFolder *)vf)->full_name, sub->full_name));
 
-	camel_object_hook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc)folder_changed, vf);
-	camel_object_hook_event((CamelObject *)sub, "deleted", (CamelObjectEventHookFunc)subfolder_deleted, vf);
-	camel_object_hook_event((CamelObject *)sub, "renamed", (CamelObjectEventHookFunc)folder_renamed, vf);
+	camel_object_hook_event ((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc)folder_changed, vf);
+	camel_object_hook_event ((CamelObject *)sub, "deleted", (CamelObjectEventHookFunc)subfolder_deleted, vf);
+	camel_object_hook_event ((CamelObject *)sub, "renamed", (CamelObjectEventHookFunc)folder_renamed, vf);
 
-	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->add_folder(vf, sub);
+	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->add_folder (vf, sub);
 
 }
 
@@ -232,74 +231,74 @@ camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
  **/
 void
 
-camel_vee_folder_remove_folder(CamelVeeFolder *vf, CamelFolder *sub)
+camel_vee_folder_remove_folder (CamelVeeFolder *vf, CamelFolder *sub)
 {
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
 	gint i;
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 
-	CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
 
-	CAMEL_VEE_FOLDER_LOCK(vf, changed_lock);
-	p->folders_changed = g_list_remove(p->folders_changed, sub);
-	CAMEL_VEE_FOLDER_UNLOCK(vf, changed_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+	p->folders_changed = g_list_remove (p->folders_changed, sub);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
 
-	if (g_list_find(p->folders, sub) == NULL) {
-		CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	if (g_list_find (p->folders, sub) == NULL) {
+		CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 		return;
 	}
 
-	camel_object_unhook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
-	camel_object_unhook_event((CamelObject *)sub, "deleted", (CamelObjectEventHookFunc) subfolder_deleted, vf);
-	camel_object_unhook_event((CamelObject *)sub, "renamed", (CamelObjectEventHookFunc) folder_renamed, vf);
+	camel_object_unhook_event ((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
+	camel_object_unhook_event ((CamelObject *)sub, "deleted", (CamelObjectEventHookFunc) subfolder_deleted, vf);
+	camel_object_unhook_event ((CamelObject *)sub, "renamed", (CamelObjectEventHookFunc) folder_renamed, vf);
 
-	p->folders = g_list_remove(p->folders, sub);
+	p->folders = g_list_remove (p->folders, sub);
 
 	/* undo the freeze state that we have imposed on this source folder */
-	CAMEL_FOLDER_LOCK(vf, change_lock);
+	CAMEL_FOLDER_LOCK (vf, change_lock);
 	for (i = 0; i < ((CamelFolder *)vf)->priv->frozen; i++)
-		camel_folder_thaw(sub);
-	CAMEL_FOLDER_UNLOCK(vf, change_lock);
+		camel_folder_thaw (sub);
+	CAMEL_FOLDER_UNLOCK (vf, change_lock);
 
-	CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 
 	if (folder_unmatched != NULL) {
-		struct _CamelVeeFolderPrivate *up = _PRIVATE(folder_unmatched);
+		struct _CamelVeeFolderPrivate *up = _PRIVATE (folder_unmatched);
 
-		CAMEL_VEE_FOLDER_LOCK(folder_unmatched, subfolder_lock);
+		CAMEL_VEE_FOLDER_LOCK (folder_unmatched, subfolder_lock);
 		/* if folder deleted, then blow it away from unmatched always, and remove all refs to it */
 		if (sub->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED) {
-			while (g_list_find(up->folders, sub)) {
-				up->folders = g_list_remove(up->folders, sub);
-				camel_object_unref((CamelObject *)sub);
+			while (g_list_find (up->folders, sub)) {
+				up->folders = g_list_remove (up->folders, sub);
+				camel_object_unref (sub);
 
 				/* undo the freeze state that Unmatched has imposed on this source folder */
-				CAMEL_FOLDER_LOCK(folder_unmatched, change_lock);
+				CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
 				for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
-					camel_folder_thaw(sub);
-				CAMEL_FOLDER_UNLOCK(folder_unmatched, change_lock);
+					camel_folder_thaw (sub);
+				CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
 			}
 		} else if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) {
-			if (g_list_find(up->folders, sub) != NULL) {
-				up->folders = g_list_remove(up->folders, sub);
-				camel_object_unref((CamelObject *)sub);
+			if (g_list_find (up->folders, sub) != NULL) {
+				up->folders = g_list_remove (up->folders, sub);
+				camel_object_unref (sub);
 
 				/* undo the freeze state that Unmatched has imposed on this source folder */
-				CAMEL_FOLDER_LOCK(folder_unmatched, change_lock);
+				CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
 				for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
-					camel_folder_thaw(sub);
-				CAMEL_FOLDER_UNLOCK(folder_unmatched, change_lock);
+					camel_folder_thaw (sub);
+				CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
 			}
 		}
-		CAMEL_VEE_FOLDER_UNLOCK(folder_unmatched, subfolder_lock);
+		CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, subfolder_lock);
 	}
 
-	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->remove_folder(vf, sub);
+	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->remove_folder (vf, sub);
 
-	if (CAMEL_IS_VEE_FOLDER(sub))
+	if (CAMEL_IS_VEE_FOLDER (sub))
 		return;
 
-	camel_object_unref((CamelObject *)sub);
+	camel_object_unref (sub);
 }
 
 /**
@@ -311,16 +310,16 @@ camel_vee_folder_remove_folder(CamelVeeFolder *vf, CamelFolder *sub)
  * Rebuild the folder @sub, if it should be.
  **/
 gint
-camel_vee_folder_rebuild_folder(CamelVeeFolder *vf, CamelFolder *sub, CamelException *ex)
+camel_vee_folder_rebuild_folder (CamelVeeFolder *vf, CamelFolder *sub, CamelException *ex)
 {
-	return ((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->rebuild_folder(vf, sub, ex);
+	return ((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->rebuild_folder (vf, sub, ex);
 }
 
 static void
-remove_folders(CamelFolder *folder, CamelFolder *foldercopy, CamelVeeFolder *vf)
+remove_folders (CamelFolder *folder, CamelFolder *foldercopy, CamelVeeFolder *vf)
 {
-	camel_vee_folder_remove_folder(vf, folder);
-	camel_object_unref((CamelObject *)folder);
+	camel_vee_folder_remove_folder (vf, folder);
+	camel_object_unref (folder);
 }
 
 /**
@@ -331,38 +330,38 @@ remove_folders(CamelFolder *folder, CamelFolder *foldercopy, CamelVeeFolder *vf)
  * Set the whole list of folder sources on a vee folder.
  **/
 void
-camel_vee_folder_set_folders(CamelVeeFolder *vf, GList *folders)
+camel_vee_folder_set_folders (CamelVeeFolder *vf, GList *folders)
 {
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
-	GHashTable *remove = g_hash_table_new(NULL, NULL);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
+	GHashTable *remove = g_hash_table_new (NULL, NULL);
 	GList *l;
 	CamelFolder *folder;
 
 	/* setup a table of all folders we have currently */
-	CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
 	l = p->folders;
 	while (l) {
-		g_hash_table_insert(remove, l->data, l->data);
-		camel_object_ref((CamelObject *)l->data);
+		g_hash_table_insert (remove, l->data, l->data);
+		camel_object_ref (l->data);
 		l = l->next;
 	}
-	CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 
 	/* if we already have the folder, ignore it, otherwise add it */
 	l = folders;
 	while (l) {
-		if ((folder = g_hash_table_lookup(remove, l->data))) {
-			g_hash_table_remove(remove, folder);
-			camel_object_unref((CamelObject *)folder);
+		if ((folder = g_hash_table_lookup (remove, l->data))) {
+			g_hash_table_remove (remove, folder);
+			camel_object_unref (folder);
 		} else {
-			camel_vee_folder_add_folder(vf, l->data);
+			camel_vee_folder_add_folder (vf, l->data);
 		}
 		l = l->next;
 	}
 
 	/* then remove any we still have */
-	g_hash_table_foreach(remove, (GHFunc)remove_folders, vf);
-	g_hash_table_destroy(remove);
+	g_hash_table_foreach (remove, (GHFunc)remove_folders, vf);
+	g_hash_table_destroy (remove);
 }
 
 /**
@@ -374,7 +373,7 @@ camel_vee_folder_set_folders(CamelVeeFolder *vf, GList *folders)
  * unique, and remain static for a given folder.
  **/
 void
-camel_vee_folder_hash_folder(CamelFolder *folder, gchar buffer[8])
+camel_vee_folder_hash_folder (CamelFolder *folder, gchar buffer[8])
 {
 	GChecksum *checksum;
 	guint8 *digest;
@@ -387,7 +386,7 @@ camel_vee_folder_hash_folder(CamelFolder *folder, gchar buffer[8])
 	digest = g_alloca (length);
 
 	checksum = g_checksum_new (G_CHECKSUM_MD5);
-	tmp = camel_service_get_url((CamelService *)folder->parent_store);
+	tmp = camel_service_get_url ((CamelService *)folder->parent_store);
 	g_checksum_update (checksum, (guchar *) tmp, -1);
 	g_free (tmp);
 	tmp = folder->full_name;
@@ -418,7 +417,7 @@ camel_vee_folder_hash_folder(CamelFolder *folder, gchar buffer[8])
  * Returns:
  **/
 CamelFolder *
-camel_vee_folder_get_location(CamelVeeFolder *vf, const CamelVeeMessageInfo *vinfo, gchar **realuid)
+camel_vee_folder_get_location (CamelVeeFolder *vf, const CamelVeeMessageInfo *vinfo, gchar **realuid)
 {
 	CamelFolder *folder;
 
@@ -426,50 +425,50 @@ camel_vee_folder_get_location(CamelVeeFolder *vf, const CamelVeeMessageInfo *vin
 
 	/* locking?  yes?  no?  although the vfolderinfo is valid when obtained
 	   the folder in it might not necessarily be so ...? */
-	if (CAMEL_IS_VEE_FOLDER(folder)) {
+	if (CAMEL_IS_VEE_FOLDER (folder)) {
 		CamelFolder *res;
 		const CamelVeeMessageInfo *vfinfo;
 
-		vfinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info(folder, camel_message_info_uid(vinfo)+8);
-		res = camel_vee_folder_get_location((CamelVeeFolder *)folder, vfinfo, realuid);
-		camel_folder_free_message_info(folder, (CamelMessageInfo *)vfinfo);
+		vfinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info (folder, camel_message_info_uid (vinfo)+8);
+		res = camel_vee_folder_get_location ((CamelVeeFolder *)folder, vfinfo, realuid);
+		camel_folder_free_message_info (folder, (CamelMessageInfo *)vfinfo);
 		return res;
 	} else {
 		if (realuid)
-			*realuid = g_strdup(camel_message_info_uid(vinfo)+8);
+			*realuid = g_strdup (camel_message_info_uid (vinfo)+8);
 
 		return folder;
 	}
 }
 
-static void vee_refresh_info(CamelFolder *folder, CamelException *ex)
+static void vee_refresh_info (CamelFolder *folder, CamelException *ex)
 {
 	CamelVeeFolder *vf = (CamelVeeFolder *)folder;
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
 	GList *node, *list;
 
-	CAMEL_VEE_FOLDER_LOCK(vf, changed_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
 	list = p->folders_changed;
 	p->folders_changed = NULL;
-	CAMEL_VEE_FOLDER_UNLOCK(vf, changed_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
 
 	node = list;
 	while (node) {
 		CamelFolder *f = node->data;
 
-		if (camel_vee_folder_rebuild_folder(vf, f, ex) == -1)
+		if (camel_vee_folder_rebuild_folder (vf, f, ex) == -1)
 			break;
 
 		node = node->next;
 	}
 
-	g_list_free(list);
+	g_list_free (list);
 }
 
 static guint32
 count_folder (CamelFolder *f, gchar *expr, CamelException *ex)
 {
-	return camel_folder_count_by_expression(f, expr, ex);
+	return camel_folder_count_by_expression (f, expr, ex);
 }
 static gint
 count_result (CamelFolderSummary *summary, const gchar *query, CamelException *ex)
@@ -479,16 +478,16 @@ count_result (CamelFolderSummary *summary, const gchar *query, CamelException *e
 	guint32 count=0;
 	gchar *expr = g_strdup_printf ("(and %s %s)", vf->expression ? vf->expression : "", query);
 	GList *node;
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
 
 	node = p->folders;
 	while (node) {
 		CamelFolder *f = node->data;
-		count += count_folder(f, expr, ex);
+		count += count_folder (f, expr, ex);
 		node = node->next;
 	}
 
-	g_free(expr);
+	g_free (expr);
 	return count;
 }
 
@@ -513,14 +512,14 @@ summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
 	record->time = s->time;
 
 	record->saved_count = s->uids->len;
-	camel_object_get(s->folder, NULL,
+	camel_object_get (s->folder, NULL,
 				 CAMEL_FOLDER_DELETED, &deleted,
 				 CAMEL_FOLDER_VISIBLE, &visible,
 				 CAMEL_FOLDER_JUNKED, &junked,
 				 CAMEL_FOLDER_JUNKED_NOT_DELETED, &junked_not_deleted,
 				 CAMEL_FOLDER_UNREAD, &unread, NULL);
 	if (1) { /* We always would do this. Just refactor the code again. */
-		/*!(((CamelVeeSummary *) s)->force_counts) && !g_getenv("FORCE_VFOLDER_COUNT")) {*/
+		/*!(((CamelVeeSummary *) s)->force_counts) && !g_getenv ("FORCE_VFOLDER_COUNT")) {*/
 		/* We should be in sync always. so use the count. Don't search.*/
 		record->junk_count = s->junk_count;
 		record->deleted_count = s->deleted_count;
@@ -548,40 +547,40 @@ summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
 		record->jnd_count = s->junk_not_deleted_count;
 	}
 
-	d(printf("%s %d %d %d %d %d\n", s->folder->full_name, record->junk_count, record->deleted_count, record->unread_count, record->visible_count, record->jnd_count));
+	d (printf ("%s %d %d %d %d %d\n", s->folder->full_name, record->junk_count, record->deleted_count, record->unread_count, record->visible_count, record->jnd_count));
 	return record;
 }
 
 static void
-vee_sync(CamelFolder *folder, gboolean expunge, CamelException *ex)
+vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
 {
 	CamelVeeFolder *vf = (CamelVeeFolder *)folder;
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
 	GList *node;
 
 	if (((CamelVeeSummary *)folder->summary)->fake_visible_count)
 		folder->summary->visible_count = ((CamelVeeSummary *)folder->summary)->fake_visible_count;
 	((CamelVeeSummary *)folder->summary)->fake_visible_count = 0;
 
-	CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
 
 	node = p->folders;
 	while (node) {
 		CamelFolder *f = node->data;
 
-		camel_folder_sync(f, expunge, ex);
-		if (camel_exception_is_set(ex) && strncmp(camel_exception_get_description(ex), "no such table", 13)) {
+		camel_folder_sync (f, expunge, ex);
+		if (camel_exception_is_set (ex) && strncmp (camel_exception_get_description (ex), "no such table", 13)) {
 			const gchar *desc;
 
-			camel_object_get(f, NULL, CAMEL_OBJECT_DESCRIPTION, &desc, NULL);
-			camel_exception_setv(ex, ex->id, _("Error storing '%s': %s"), desc, ex->desc);
-			g_warning ("%s", camel_exception_get_description(ex));
+			camel_object_get (f, NULL, CAMEL_OBJECT_DESCRIPTION, &desc, NULL);
+			camel_exception_setv (ex, ex->id, _("Error storing '%s': %s"), desc, ex->desc);
+			g_warning ("%s", camel_exception_get_description (ex));
 		} else
 			camel_exception_clear (ex);
 
 		/* auto update vfolders shouldn't need a rebuild */
 /*		if ((vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO) == 0 */
-/*		    && camel_vee_folder_rebuild_folder(vf, f, ex) == -1) */
+/*		    && camel_vee_folder_rebuild_folder (vf, f, ex) == -1) */
 /*			break; */
 
 		node = node->next;
@@ -599,10 +598,10 @@ vee_sync(CamelFolder *folder, gboolean expunge, CamelException *ex)
 	 * actually rebuilding. */
 #if 0
 	if (node == NULL) {
-		CAMEL_VEE_FOLDER_LOCK(vf, changed_lock);
-		g_list_free(p->folders_changed);
+		CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+		g_list_free (p->folders_changed);
 		p->folders_changed = NULL;
-		CAMEL_VEE_FOLDER_UNLOCK(vf, changed_lock);
+		CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
 	}
 #endif
 	if (vf->priv->unread_vfolder == 1) {
@@ -614,7 +613,7 @@ vee_sync(CamelFolder *folder, gboolean expunge, CamelException *ex)
 		for (i=0; i < count; i++) {
 			CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index (folder->summary, i);
 			if (mi->old_flags & CAMEL_MESSAGE_DELETED) {
-				del = g_slist_prepend (del, (gpointer) camel_pstring_strdup(((CamelMessageInfo *)mi)->uid));
+				del = g_slist_prepend (del, (gpointer) camel_pstring_strdup (((CamelMessageInfo *)mi)->uid));
 				camel_folder_summary_remove_index_fast (folder->summary, i);
 				count--;
 				i--;
@@ -626,9 +625,9 @@ vee_sync(CamelFolder *folder, gboolean expunge, CamelException *ex)
 		g_slist_foreach (del, (GFunc) camel_pstring_free, NULL);
 		g_slist_free (del);
 	}
-	CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 
-	camel_object_state_write(vf);
+	camel_object_state_write (vf);
 }
 
 static void
@@ -636,21 +635,21 @@ vee_expunge (CamelFolder *folder, CamelException *ex)
 {
 	/* Force it to rebuild the counts, when some folders were expunged. */
 	((CamelVeeSummary *) folder->summary)->force_counts = TRUE;
-	((CamelFolderClass *)((CamelObject *)folder)->klass)->sync(folder, TRUE, ex);
+	((CamelFolderClass *)((CamelObject *)folder)->klass)->sync (folder, TRUE, ex);
 }
 
 static CamelMimeMessage *
-vee_get_message(CamelFolder *folder, const gchar *uid, CamelException *ex)
+vee_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
 {
 	CamelVeeMessageInfo *mi;
 	CamelMimeMessage *msg = NULL;
 
-	mi = (CamelVeeMessageInfo *)camel_folder_summary_uid(folder->summary, uid);
+	mi = (CamelVeeMessageInfo *)camel_folder_summary_uid (folder->summary, uid);
 	if (mi) {
-		msg =  camel_folder_get_message(mi->summary->folder, camel_message_info_uid(mi)+8, ex);
-		camel_message_info_free((CamelMessageInfo *)mi);
+		msg =  camel_folder_get_message (mi->summary->folder, camel_message_info_uid (mi)+8, ex);
+		camel_message_info_free ((CamelMessageInfo *)mi);
 	} else {
-		camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
+		camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID,
 				     _("No such message %s in %s"), uid,
 				     folder->name);
 	}
@@ -659,14 +658,14 @@ vee_get_message(CamelFolder *folder, const gchar *uid, CamelException *ex)
 }
 
 static guint32
-vee_count_by_expression(CamelFolder *folder, const gchar *expression, CamelException *ex)
+vee_count_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
 {
 	GList *node;
 	gchar *expr;
 	guint32 count = 0;
 	CamelVeeFolder *vf = (CamelVeeFolder *)folder;
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
-	GHashTable *searched = g_hash_table_new(NULL, NULL);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
+	GHashTable *searched = g_hash_table_new (NULL, NULL);
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 
 	if (vf != folder_unmatched)
@@ -679,27 +678,27 @@ vee_count_by_expression(CamelFolder *folder, const gchar *expression, CamelExcep
 		CamelFolder *f = node->data;
 
 		/* make sure we only search each folder once - for unmatched folder to work right */
-		if (g_hash_table_lookup(searched, f) == NULL) {
-			count += camel_folder_count_by_expression(f, expr, ex);
-			g_hash_table_insert(searched, f, f);
+		if (g_hash_table_lookup (searched, f) == NULL) {
+			count += camel_folder_count_by_expression (f, expr, ex);
+			g_hash_table_insert (searched, f, f);
 		}
-		node = g_list_next(node);
+		node = g_list_next (node);
 	}
 
-	g_free(expr);
+	g_free (expr);
 
-	g_hash_table_destroy(searched);
+	g_hash_table_destroy (searched);
 	return count;
 }
 static GPtrArray *
-vee_search_by_expression(CamelFolder *folder, const gchar *expression, CamelException *ex)
+vee_search_by_expression (CamelFolder *folder, const gchar *expression, CamelException *ex)
 {
 	GList *node;
 	GPtrArray *matches, *result = g_ptr_array_new ();
 	gchar *expr;
 	CamelVeeFolder *vf = (CamelVeeFolder *)folder;
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
-	GHashTable *searched = g_hash_table_new(NULL, NULL);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
+	GHashTable *searched = g_hash_table_new (NULL, NULL);
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 
 	if (vf != folder_unmatched)
@@ -714,50 +713,50 @@ vee_search_by_expression(CamelFolder *folder, const gchar *expression, CamelExce
 		gchar hash[8];
 
 		/* make sure we only search each folder once - for unmatched folder to work right */
-		if (g_hash_table_lookup(searched, f) == NULL) {
-			camel_vee_folder_hash_folder(f, hash);
-			matches = camel_folder_search_by_expression(f, expr, ex);
-			if (camel_exception_is_set(ex) && strncmp(camel_exception_get_description(ex), "no such table", 13)) {
-				camel_exception_clear(ex);
+		if (g_hash_table_lookup (searched, f) == NULL) {
+			camel_vee_folder_hash_folder (f, hash);
+			matches = camel_folder_search_by_expression (f, expr, ex);
+			if (camel_exception_is_set (ex) && strncmp (camel_exception_get_description (ex), "no such table", 13)) {
+				camel_exception_clear (ex);
 			}
 			if (matches) {
 				for (i = 0; i < matches->len; i++) {
 					gchar *uid = matches->pdata[i], *vuid;
 
-					vuid = g_malloc(strlen(uid)+9);
-					memcpy(vuid, hash, 8);
-					strcpy(vuid+8, uid);
-					g_ptr_array_add(result, (gpointer) camel_pstring_strdup(vuid));
+					vuid = g_malloc (strlen (uid)+9);
+					memcpy (vuid, hash, 8);
+					strcpy (vuid+8, uid);
+					g_ptr_array_add (result, (gpointer) camel_pstring_strdup (vuid));
 					g_free (vuid);
 				}
-				camel_folder_search_free(f, matches);
+				camel_folder_search_free (f, matches);
 			}
-			g_hash_table_insert(searched, f, f);
+			g_hash_table_insert (searched, f, f);
 		}
-		node = g_list_next(node);
+		node = g_list_next (node);
 	}
 
-	g_free(expr);
+	g_free (expr);
 
-	g_hash_table_destroy(searched);
-	d(printf("returning %d\n", result->len));
+	g_hash_table_destroy (searched);
+	d (printf ("returning %d\n", result->len));
 	return result;
 }
 
 static GPtrArray *
-vee_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex)
+vee_search_by_uids (CamelFolder *folder, const gchar *expression, GPtrArray *uids, CamelException *ex)
 {
 	GList *node;
 	GPtrArray *matches, *result = g_ptr_array_new ();
-	GPtrArray *folder_uids = g_ptr_array_new();
+	GPtrArray *folder_uids = g_ptr_array_new ();
 	gchar *expr;
 	CamelVeeFolder *vf = (CamelVeeFolder *)folder;
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
-	GHashTable *searched = g_hash_table_new(NULL, NULL);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
+	GHashTable *searched = g_hash_table_new (NULL, NULL);
 
-	CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
 
-	expr = g_strdup_printf("(and %s %s)", vf->expression ? vf->expression : "", expression);
+	expr = g_strdup_printf ("(and %s %s)", vf->expression ? vf->expression : "", expression);
 	node = p->folders;
 	while (node) {
 		CamelFolder *f = node->data;
@@ -765,87 +764,87 @@ vee_search_by_uids(CamelFolder *folder, const gchar *expression, GPtrArray *uids
 		gchar hash[8];
 
 		/* make sure we only search each folder once - for unmatched folder to work right */
-		if (g_hash_table_lookup(searched, f) == NULL) {
-			camel_vee_folder_hash_folder(f, hash);
+		if (g_hash_table_lookup (searched, f) == NULL) {
+			camel_vee_folder_hash_folder (f, hash);
 
 			/* map the vfolder uid's to the source folder uid's first */
-			g_ptr_array_set_size(folder_uids, 0);
+			g_ptr_array_set_size (folder_uids, 0);
 			for (i=0;i<uids->len;i++) {
 				gchar *uid = uids->pdata[i];
 
-				if (strlen(uid) >= 8 && strncmp(uid, hash, 8) == 0)
-					g_ptr_array_add(folder_uids, uid+8);
+				if (strlen (uid) >= 8 && strncmp (uid, hash, 8) == 0)
+					g_ptr_array_add (folder_uids, uid+8);
 			}
 			if (folder_uids->len > 0) {
-				matches = camel_folder_search_by_uids(f, expr, folder_uids, ex);
+				matches = camel_folder_search_by_uids (f, expr, folder_uids, ex);
 				if (matches) {
 					for (i = 0; i < matches->len; i++) {
 						gchar *uid = matches->pdata[i], *vuid;
 
-						vuid = g_malloc(strlen(uid)+9);
-						memcpy(vuid, hash, 8);
-						strcpy(vuid+8, uid);
-						g_ptr_array_add(result, (gpointer) camel_pstring_strdup(vuid));
-						g_free(vuid);
+						vuid = g_malloc (strlen (uid)+9);
+						memcpy (vuid, hash, 8);
+						strcpy (vuid+8, uid);
+						g_ptr_array_add (result, (gpointer) camel_pstring_strdup (vuid));
+						g_free (vuid);
 					}
-					camel_folder_search_free(f, matches);
+					camel_folder_search_free (f, matches);
 				} else {
-					g_warning("Search failed: %s", camel_exception_get_description(ex));
+					g_warning ("Search failed: %s", camel_exception_get_description (ex));
 				}
 			}
-			g_hash_table_insert(searched, f, f);
+			g_hash_table_insert (searched, f, f);
 		}
-		node = g_list_next(node);
+		node = g_list_next (node);
 	}
 
-	g_free(expr);
-	CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	g_free (expr);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 
-	g_hash_table_destroy(searched);
-	g_ptr_array_free(folder_uids, TRUE);
+	g_hash_table_destroy (searched);
+	g_ptr_array_free (folder_uids, TRUE);
 
 	return result;
 }
 
 static void
-vee_append_message(CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex)
+vee_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, gchar **appended_uid, CamelException *ex)
 {
-	camel_exception_set(ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot copy or move messages into a Virtual Folder"));
+	camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot copy or move messages into a Virtual Folder"));
 }
 
 static void
 vee_transfer_messages_to (CamelFolder *folder, GPtrArray *uids, CamelFolder *dest, GPtrArray **transferred_uids, gboolean delete_originals, CamelException *ex)
 {
-	camel_exception_set(ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot copy or move messages into a Virtual Folder"));
+	camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot copy or move messages into a Virtual Folder"));
 }
 
-static void vee_rename(CamelFolder *folder, const gchar *new)
+static void vee_rename (CamelFolder *folder, const gchar *new)
 {
 	/*CamelVeeFolder *vf = (CamelVeeFolder *)folder;*/
 
-	((CamelFolderClass *)camel_vee_folder_parent)->rename(folder, new);
+	((CamelFolderClass *)camel_vee_folder_parent)->rename (folder, new);
 }
 
-static void vee_delete(CamelFolder *folder)
+static void vee_delete (CamelFolder *folder)
 {
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(folder);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (folder);
 
 	/* NB: this is never called on UNMTACHED */
 
-	CAMEL_VEE_FOLDER_LOCK(folder, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (folder, subfolder_lock);
 	while (p->folders) {
 		CamelFolder *f = p->folders->data;
 
-		camel_object_ref(f);
-		CAMEL_VEE_FOLDER_UNLOCK(folder, subfolder_lock);
+		camel_object_ref (f);
+		CAMEL_VEE_FOLDER_UNLOCK (folder, subfolder_lock);
 
-		camel_vee_folder_remove_folder((CamelVeeFolder *)folder, f);
-		camel_object_unref(f);
-		CAMEL_VEE_FOLDER_LOCK(folder, subfolder_lock);
+		camel_vee_folder_remove_folder ((CamelVeeFolder *)folder, f);
+		camel_object_unref (f);
+		CAMEL_VEE_FOLDER_LOCK (folder, subfolder_lock);
 	}
-	CAMEL_VEE_FOLDER_UNLOCK(folder, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (folder, subfolder_lock);
 
-	((CamelFolderClass *)camel_vee_folder_parent)->delete(folder);
+	((CamelFolderClass *)camel_vee_folder_parent)->delete (folder);
 	((CamelVeeFolder *)folder)->deleted = TRUE;
 }
 
@@ -861,20 +860,20 @@ static void vee_delete(CamelFolder *folder)
  * The only current example of a correlating expression is one that uses
  * "match-threads". */
 static gboolean
-expression_is_correlating(const gchar *expr)
+expression_is_correlating (const gchar *expr)
 {
 	/* XXX: Actually parse the expression to avoid triggering on
 	 * "match-threads" in the text the user is searching for! */
-	return (strstr(expr, "match-threads") != NULL);
+	return (strstr (expr, "match-threads") != NULL);
 }
 
 /* must be called with summary_lock held */
 static CamelVeeMessageInfo *
-vee_folder_add_uid(CamelVeeFolder *vf, CamelFolder *f, const gchar *inuid, const gchar hash[8])
+vee_folder_add_uid (CamelVeeFolder *vf, CamelFolder *f, const gchar *inuid, const gchar hash[8])
 {
 	CamelVeeMessageInfo *mi = NULL;
 
-	mi = camel_vee_summary_add((CamelVeeSummary *)((CamelFolder *)vf)->summary, f->summary, (gchar *)inuid, hash);
+	mi = camel_vee_summary_add ((CamelVeeSummary *)((CamelFolder *)vf)->summary, f->summary, (gchar *)inuid, hash);
 	return mi;
 }
 
@@ -893,7 +892,7 @@ vee_folder_add_uid_test (CamelVeeFolder *vf, CamelFolder *f, const gchar *inuid,
 }
 
 static void
-vee_folder_remove_folder(CamelVeeFolder *vf, CamelFolder *source)
+vee_folder_remove_folder (CamelVeeFolder *vf, CamelFolder *source)
 {
 	gint i, count, n, still = FALSE, start, last;
 	gchar *oldkey;
@@ -912,122 +911,122 @@ vee_folder_remove_folder(CamelVeeFolder *vf, CamelFolder *source)
 	if ((source->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED))
 		killun = TRUE;
 
-	CAMEL_VEE_FOLDER_LOCK(vf, summary_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, summary_lock);
 
 	if (folder_unmatched != NULL) {
 		/* check if this folder is still to be part of unmatched */
 		if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !killun) {
-			CAMEL_VEE_FOLDER_LOCK(folder_unmatched, subfolder_lock);
-			still = g_list_find(_PRIVATE(folder_unmatched)->folders, source) != NULL;
-			CAMEL_VEE_FOLDER_UNLOCK(folder_unmatched, subfolder_lock);
-			camel_vee_folder_hash_folder(source, hash);
+			CAMEL_VEE_FOLDER_LOCK (folder_unmatched, subfolder_lock);
+			still = g_list_find (_PRIVATE (folder_unmatched)->folders, source) != NULL;
+			CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, subfolder_lock);
+			camel_vee_folder_hash_folder (source, hash);
 		}
 
-		CAMEL_VEE_FOLDER_LOCK(folder_unmatched, summary_lock);
+		CAMEL_VEE_FOLDER_LOCK (folder_unmatched, summary_lock);
 
 		/* See if we just blow all uid's from this folder away from unmatched, regardless */
 		if (killun) {
 			start = -1;
 			last = -1;
-			count = camel_folder_summary_count(((CamelFolder *)folder_unmatched)->summary);
+			count = camel_folder_summary_count (((CamelFolder *)folder_unmatched)->summary);
 			for (i=0;i<count;i++) {
-				CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index(((CamelFolder *)folder_unmatched)->summary, i);
+				CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index (((CamelFolder *)folder_unmatched)->summary, i);
 
 				if (mi) {
 					if (mi->summary == ssummary) {
-						camel_folder_change_info_remove_uid(folder_unmatched->changes, camel_message_info_uid(mi));
+						camel_folder_change_info_remove_uid (folder_unmatched->changes, camel_message_info_uid (mi));
 						if (last == -1) {
 							last = start = i;
 						} else if (last+1 == i) {
 							last = i;
 						} else {
-							camel_folder_summary_remove_range(((CamelFolder *)folder_unmatched)->summary, start, last);
+							camel_folder_summary_remove_range (((CamelFolder *)folder_unmatched)->summary, start, last);
 							i -= (last-start)+1;
 							start = last = i;
 						}
 					}
-					camel_message_info_free((CamelMessageInfo *)mi);
+					camel_message_info_free ((CamelMessageInfo *)mi);
 				}
 			}
 			if (last != -1)
-				camel_folder_summary_remove_range(((CamelFolder *)folder_unmatched)->summary, start, last);
+				camel_folder_summary_remove_range (((CamelFolder *)folder_unmatched)->summary, start, last);
 		}
 	}
 
 	/*FIXME: This can be optimized a lot like, searching for UID in the summary uids */
 	start = -1;
 	last = -1;
-	count = camel_folder_summary_count(folder->summary);
+	count = camel_folder_summary_count (folder->summary);
 	for (i=0;i<count;i++) {
-		CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index(folder->summary, i);
+		CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index (folder->summary, i);
 		if (mi) {
 			if (mi->summary == ssummary) {
-				const gchar *uid = camel_message_info_uid(mi);
+				const gchar *uid = camel_message_info_uid (mi);
 
-				camel_folder_change_info_remove_uid(vf->changes, uid);
+				camel_folder_change_info_remove_uid (vf->changes, uid);
 
 				if (last == -1) {
 					last = start = i;
 				} else if (last+1 == i) {
 					last = i;
 				} else {
-					camel_folder_summary_remove_range(folder->summary, start, last);
+					camel_folder_summary_remove_range (folder->summary, start, last);
 					i -= (last-start)+1;
 					start = last = i;
 				}
 				if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && folder_unmatched != NULL) {
 					if (still) {
-						if (g_hash_table_lookup_extended(unmatched_uids, uid, (gpointer *)&oldkey, &oldval)) {
+						if (g_hash_table_lookup_extended (unmatched_uids, uid, (gpointer *)&oldkey, &oldval)) {
 							n = GPOINTER_TO_INT (oldval);
 							if (n == 1) {
-								g_hash_table_remove(unmatched_uids, oldkey);
+								g_hash_table_remove (unmatched_uids, oldkey);
 								if (vee_folder_add_uid_test (folder_unmatched, source, oldkey+8, hash)) {
-									camel_folder_change_info_add_uid(folder_unmatched->changes, oldkey);
+									camel_folder_change_info_add_uid (folder_unmatched->changes, oldkey);
 								}
-								g_free(oldkey);
+								g_free (oldkey);
 							} else {
-								g_hash_table_insert(unmatched_uids, oldkey, GINT_TO_POINTER(n-1));
+								g_hash_table_insert (unmatched_uids, oldkey, GINT_TO_POINTER (n-1));
 							}
 						}
 					} else {
-						if (g_hash_table_lookup_extended(unmatched_uids, camel_message_info_uid(mi), (gpointer *)&oldkey, &oldval)) {
-							g_hash_table_remove(unmatched_uids, oldkey);
-							g_free(oldkey);
+						if (g_hash_table_lookup_extended (unmatched_uids, camel_message_info_uid (mi), (gpointer *)&oldkey, &oldval)) {
+							g_hash_table_remove (unmatched_uids, oldkey);
+							g_free (oldkey);
 						}
 					}
 				}
 			}
-			camel_message_info_free((CamelMessageInfo *)mi);
+			camel_message_info_free ((CamelMessageInfo *)mi);
 		}
 	}
 
 	if (last != -1)
-		camel_folder_summary_remove_range(folder->summary, start, last);
+		camel_folder_summary_remove_range (folder->summary, start, last);
 
 	if (folder_unmatched) {
-		if (camel_folder_change_info_changed(folder_unmatched->changes)) {
+		if (camel_folder_change_info_changed (folder_unmatched->changes)) {
 			unmatched_changes = folder_unmatched->changes;
-			folder_unmatched->changes = camel_folder_change_info_new();
+			folder_unmatched->changes = camel_folder_change_info_new ();
 		}
 
-		CAMEL_VEE_FOLDER_UNLOCK(folder_unmatched, summary_lock);
+		CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, summary_lock);
 	}
 
-	if (camel_folder_change_info_changed(vf->changes)) {
+	if (camel_folder_change_info_changed (vf->changes)) {
 		vf_changes = vf->changes;
-		vf->changes = camel_folder_change_info_new();
+		vf->changes = camel_folder_change_info_new ();
 	}
 
-	CAMEL_VEE_FOLDER_UNLOCK(vf, summary_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, summary_lock);
 
 	if (unmatched_changes) {
-		camel_object_trigger_event((CamelObject *)folder_unmatched, "folder_changed", unmatched_changes);
-		camel_folder_change_info_free(unmatched_changes);
+		camel_object_trigger_event ((CamelObject *)folder_unmatched, "folder_changed", unmatched_changes);
+		camel_folder_change_info_free (unmatched_changes);
 	}
 
 	if (vf_changes) {
-		camel_object_trigger_event((CamelObject *)vf, "folder_changed", vf_changes);
-		camel_folder_change_info_free(vf_changes);
+		camel_object_trigger_event ((CamelObject *)vf, "folder_changed", vf_changes);
+		camel_folder_change_info_free (vf_changes);
 	}
 }
 
@@ -1041,33 +1040,33 @@ struct _update_data {
 };
 
 static void
-unmatched_check_uid(gchar *uidin, gpointer value, struct _update_data *u)
+unmatched_check_uid (gchar *uidin, gpointer value, struct _update_data *u)
 {
 	gchar *uid;
 	gint n;
 
-	uid = alloca(strlen(uidin)+9);
-	memcpy(uid, u->hash, 8);
-	strcpy(uid+8, uidin);
-	n = GPOINTER_TO_INT(g_hash_table_lookup(u->unmatched_uids, uid));
+	uid = alloca (strlen (uidin)+9);
+	memcpy (uid, u->hash, 8);
+	strcpy (uid+8, uidin);
+	n = GPOINTER_TO_INT (g_hash_table_lookup (u->unmatched_uids, uid));
 	if (n == 0) {
 		if (vee_folder_add_uid_test (u->folder_unmatched, u->source, uidin, u->hash))
-			camel_folder_change_info_add_uid(u->folder_unmatched->changes, uid);
+			camel_folder_change_info_add_uid (u->folder_unmatched->changes, uid);
 	} else {
-		CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_uid(((CamelFolder *)u->folder_unmatched)->summary, uid);
+		CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_uid (((CamelFolder *)u->folder_unmatched)->summary, uid);
 		if (mi) {
 			CamelException ex = CAMEL_EXCEPTION_INITIALISER;
 			camel_db_delete_uid_from_vfolder_transaction (((CamelFolder *)u->folder_unmatched)->parent_store->cdb_w, ((CamelFolder *)u->folder_unmatched)->full_name, uid, &ex);
 			camel_folder_summary_remove_uid_fast (((CamelFolder *)u->folder_unmatched)->summary, uid);
-			camel_folder_change_info_remove_uid(u->folder_unmatched->changes, uid);
-			camel_message_info_free((CamelMessageInfo *)mi);
+			camel_folder_change_info_remove_uid (u->folder_unmatched->changes, uid);
+			camel_message_info_free ((CamelMessageInfo *)mi);
 			camel_exception_clear (&ex);
 		}
 	}
 }
 
 static void
-folder_added_uid(gchar *uidin, gpointer value, struct _update_data *u)
+folder_added_uid (gchar *uidin, gpointer value, struct _update_data *u)
 {
 	CamelVeeMessageInfo *mi;
 	gchar *oldkey;
@@ -1075,21 +1074,21 @@ folder_added_uid(gchar *uidin, gpointer value, struct _update_data *u)
 	gint n;
 
 	if ((mi = vee_folder_add_uid (u->vf, u->source, uidin, u->hash)) != NULL) {
-		camel_folder_change_info_add_uid(u->vf->changes, camel_message_info_uid(mi));
+		camel_folder_change_info_add_uid (u->vf->changes, camel_message_info_uid (mi));
 		/* FIXME[disk-summary] Handle exceptions */
 		/* FIXME[disk-summary] Make all these as transactions, just
 		 * testing atm */
 		if (u->rebuilt && !u->correlating) {
 			CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-			camel_db_add_to_vfolder_transaction (((CamelFolder *) u->vf)->parent_store->cdb_w, ((CamelFolder *) u->vf)->full_name, camel_message_info_uid(mi), &ex);
+			camel_db_add_to_vfolder_transaction (((CamelFolder *) u->vf)->parent_store->cdb_w, ((CamelFolder *) u->vf)->full_name, camel_message_info_uid (mi), &ex);
 			camel_exception_clear (&ex);
 		}
-		if (!CAMEL_IS_VEE_FOLDER(u->source) && u->unmatched_uids != NULL) {
-			if (g_hash_table_lookup_extended(u->unmatched_uids, camel_message_info_uid(mi), (gpointer *)&oldkey, &oldval)) {
+		if (!CAMEL_IS_VEE_FOLDER (u->source) && u->unmatched_uids != NULL) {
+			if (g_hash_table_lookup_extended (u->unmatched_uids, camel_message_info_uid (mi), (gpointer *)&oldkey, &oldval)) {
 				n = GPOINTER_TO_INT (oldval);
-				g_hash_table_insert(u->unmatched_uids, oldkey, GINT_TO_POINTER(n+1));
+				g_hash_table_insert (u->unmatched_uids, oldkey, GINT_TO_POINTER (n+1));
 			} else {
-				g_hash_table_insert(u->unmatched_uids, g_strdup(camel_message_info_uid(mi)), GINT_TO_POINTER(1));
+				g_hash_table_insert (u->unmatched_uids, g_strdup (camel_message_info_uid (mi)), GINT_TO_POINTER (1));
 			}
 		}
 
@@ -1099,7 +1098,7 @@ folder_added_uid(gchar *uidin, gpointer value, struct _update_data *u)
 
 /* build query contents for a single folder */
 static gint
-vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
+vee_rebuild_folder (CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
 {
 	GPtrArray *match, *all;
 	GHashTable *allhash, *matchhash, *fullhash;
@@ -1117,15 +1116,15 @@ vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
 	/* Since the source of a correlating vfolder has to be requeried in
 	 * full every time it changes, caching the results in the db is not
 	 * worth the effort.  Thus, DB use is conditioned on !correlating. */
-	gboolean correlating = expression_is_correlating(vf->expression);
+	gboolean correlating = expression_is_correlating (vf->expression);
 
 	if (vf == folder_unmatched)
 		return 0;
 
-	camel_vee_folder_hash_folder(source, u.hash);
-	shash = g_strdup_printf("%c%c%c%c%c%c%c%c", u.hash[0], u.hash[1], u.hash[2], u.hash[3], u.hash[4], u.hash[5], u.hash[6], u.hash[7]);
+	camel_vee_folder_hash_folder (source, u.hash);
+	shash = g_strdup_printf ("%c%c%c%c%c%c%c%c", u.hash[0], u.hash[1], u.hash[2], u.hash[3], u.hash[4], u.hash[5], u.hash[6], u.hash[7]);
 	if (!g_hash_table_lookup (vf->hashes, shash)) {
-		g_hash_table_insert (vf->hashes, g_strdup(shash), source->summary);
+		g_hash_table_insert (vf->hashes, g_strdup (shash), source->summary);
 	}
 	if (folder_unmatched && !g_hash_table_lookup (folder_unmatched->hashes, shash)) {
 		g_hash_table_insert (folder_unmatched->hashes, g_strdup (shash), source->summary);
@@ -1133,7 +1132,7 @@ vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
 
 	/* if we have no expression, or its been cleared, then act as if no matches */
 	if (vf->expression == NULL) {
-		match = g_ptr_array_new();
+		match = g_ptr_array_new ();
 	} else {
 		if (!correlating) {
 			/* Load the folder results from the DB. */
@@ -1143,14 +1142,14 @@ vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
 			/* We take this to mean the results have not been cached.
 			 * XXX: It will also trigger if the result set is empty. */
 			match == NULL) {
-			match = camel_folder_search_by_expression(source, vf->expression, ex);
+			match = camel_folder_search_by_expression (source, vf->expression, ex);
 			if (match == NULL) /* Search failed */
 				return 0;
 			rebuilded = TRUE;
 		}
 
 	}
-	dd(printf("vee_rebuild_folder(%s <- %s %s): match %d, correlating %d, rebuilded %d\n",
+	dd (printf ("vee_rebuild_folder (%s <- %s %s): match %d, correlating %d, rebuilded %d\n",
 		folder->full_name, source->full_name, shash, match->len, correlating, rebuilded));
 
 	u.source = source;
@@ -1160,27 +1159,27 @@ vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
 	u.rebuilt = rebuilded;
 	u.correlating = correlating;
 
-	CAMEL_VEE_FOLDER_LOCK(vf, summary_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, summary_lock);
 
 	/* we build 2 hash tables, one for all uid's not matched, the
 	   other for all matched uid's, we just ref the real memory */
-	matchhash = g_hash_table_new(g_str_hash, g_str_equal);
+	matchhash = g_hash_table_new (g_str_hash, g_str_equal);
 	for (i=0;i<match->len;i++)
-		g_hash_table_insert(matchhash, match->pdata[i], GINT_TO_POINTER (1));
+		g_hash_table_insert (matchhash, match->pdata[i], GINT_TO_POINTER (1));
 
-	allhash = g_hash_table_new(g_str_hash, g_str_equal);
-	fullhash = g_hash_table_new(g_str_hash, g_str_equal);
-	all = camel_folder_summary_array(source->summary);
+	allhash = g_hash_table_new (g_str_hash, g_str_equal);
+	fullhash = g_hash_table_new (g_str_hash, g_str_equal);
+	all = camel_folder_summary_array (source->summary);
 	for (i=0;i<all->len;i++) {
-		if (g_hash_table_lookup(matchhash, all->pdata[i]) == NULL)
-			g_hash_table_insert(allhash, all->pdata[i], GINT_TO_POINTER (1));
-		g_hash_table_insert(fullhash, all->pdata[i], GINT_TO_POINTER (1));
+		if (g_hash_table_lookup (matchhash, all->pdata[i]) == NULL)
+			g_hash_table_insert (allhash, all->pdata[i], GINT_TO_POINTER (1));
+		g_hash_table_insert (fullhash, all->pdata[i], GINT_TO_POINTER (1));
 
 	}
 	/* remove uids that can't be found in the source folder */
 	count = match->len;
 	for (i=0; i<count; i++) {
-		if (!g_hash_table_lookup(fullhash, match->pdata[i])) {
+		if (!g_hash_table_lookup (fullhash, match->pdata[i])) {
 			g_hash_table_remove (matchhash, match->pdata[i]);
 			del_list = g_slist_prepend (del_list, match->pdata[i]); /* Free the original */
 			g_ptr_array_remove_index_fast (match, i);
@@ -1191,79 +1190,79 @@ vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
 	}
 
 	if (folder_unmatched != NULL)
-		CAMEL_VEE_FOLDER_LOCK(folder_unmatched, summary_lock);
+		CAMEL_VEE_FOLDER_LOCK (folder_unmatched, summary_lock);
 
 	/* scan, looking for "old" uid's to be removed. "old" uid's
 	   are those that are from previous added sources (not in
 	   current source) */
 	start = -1;
 	last = -1;
-	count = camel_folder_summary_count(folder->summary);
+	count = camel_folder_summary_count (folder->summary);
 	for (i=0;i<count;i++) {
-		CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index(folder->summary, i);
+		CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index (folder->summary, i);
 
 		if (mi) {
 			if (mi->summary == ssummary) {
-				gchar *uid = (gchar *)camel_message_info_uid(mi), *oldkey;
+				gchar *uid = (gchar *)camel_message_info_uid (mi), *oldkey;
 				gpointer oldval;
 
-				if (g_hash_table_lookup(matchhash, uid+8) == NULL) {
+				if (g_hash_table_lookup (matchhash, uid+8) == NULL) {
 					if (last == -1) {
 						last = start = i;
 					} else if (last+1 == i) {
 						last = i;
 					} else {
-						camel_folder_summary_remove_range(folder->summary, start, last);
+						camel_folder_summary_remove_range (folder->summary, start, last);
 						i -= (last-start)+1;
 						start = last = i;
 					}
-					camel_folder_change_info_remove_uid(vf->changes, camel_message_info_uid(mi));
-					if (!CAMEL_IS_VEE_FOLDER(source)
+					camel_folder_change_info_remove_uid (vf->changes, camel_message_info_uid (mi));
+					if (!CAMEL_IS_VEE_FOLDER (source)
 					    && unmatched_uids != NULL
-					    && g_hash_table_lookup_extended(unmatched_uids, uid, (gpointer *)&oldkey, &oldval)) {
+					    && g_hash_table_lookup_extended (unmatched_uids, uid, (gpointer *)&oldkey, &oldval)) {
 						n = GPOINTER_TO_INT (oldval);
 						if (n == 1) {
-							g_hash_table_remove(unmatched_uids, oldkey);
-							g_free(oldkey);
+							g_hash_table_remove (unmatched_uids, oldkey);
+							g_free (oldkey);
 						} else {
-							g_hash_table_insert(unmatched_uids, oldkey, GINT_TO_POINTER(n-1));
+							g_hash_table_insert (unmatched_uids, oldkey, GINT_TO_POINTER (n-1));
 						}
 					}
 				} else {
-					g_hash_table_remove(matchhash, uid+8);
+					g_hash_table_remove (matchhash, uid+8);
 				}
 			}
-			camel_message_info_free((CamelMessageInfo *)mi);
+			camel_message_info_free ((CamelMessageInfo *)mi);
 		}
 	}
 	if (last != -1)
-		camel_folder_summary_remove_range(folder->summary, start, last);
+		camel_folder_summary_remove_range (folder->summary, start, last);
 
 	/* now matchhash contains any new uid's, add them, etc */
 	if (rebuilded && !correlating) {
 		camel_db_begin_transaction (folder->parent_store->cdb_w, NULL);
 
 	}
-	g_hash_table_foreach(matchhash, (GHFunc)folder_added_uid, &u);
+	g_hash_table_foreach (matchhash, (GHFunc)folder_added_uid, &u);
 
 	if (rebuilded && !correlating)
 		camel_db_end_transaction (folder->parent_store->cdb_w, NULL);
 
 	if (folder_unmatched != NULL) {
 		/* scan unmatched, remove any that have vanished, etc */
-		count = camel_folder_summary_count(((CamelFolder *)folder_unmatched)->summary);
+		count = camel_folder_summary_count (((CamelFolder *)folder_unmatched)->summary);
 		for (i=0;i<count;i++) {
 			gchar *uid = camel_folder_summary_uid_from_index (((CamelFolder *)folder_unmatched)->summary, i);
 
 			if (uid) {
 				if (strncmp (uid, u.hash, 8) == 0) {
-					if (g_hash_table_lookup(allhash, uid+8) == NULL) {
+					if (g_hash_table_lookup (allhash, uid+8) == NULL) {
 						/* no longer exists at all, just remove it entirely */
-						camel_folder_summary_remove_index_fast(((CamelFolder *)folder_unmatched)->summary, i);
-						camel_folder_change_info_remove_uid(folder_unmatched->changes, uid);
+						camel_folder_summary_remove_index_fast (((CamelFolder *)folder_unmatched)->summary, i);
+						camel_folder_change_info_remove_uid (folder_unmatched->changes, uid);
 						i--;
 					} else {
-						g_hash_table_remove(allhash, uid+8);
+						g_hash_table_remove (allhash, uid+8);
 					}
 				}
 				g_free (uid);
@@ -1271,30 +1270,30 @@ vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
 		}
 
 		/* now allhash contains all potentially new uid's for the unmatched folder, process */
-		if (!CAMEL_IS_VEE_FOLDER(source))
-			g_hash_table_foreach(allhash, (GHFunc)unmatched_check_uid, &u);
+		if (!CAMEL_IS_VEE_FOLDER (source))
+			g_hash_table_foreach (allhash, (GHFunc)unmatched_check_uid, &u);
 
 		/* copy any changes so we can raise them outside the lock */
-		if (camel_folder_change_info_changed(folder_unmatched->changes)) {
+		if (camel_folder_change_info_changed (folder_unmatched->changes)) {
 			unmatched_changes = folder_unmatched->changes;
-			folder_unmatched->changes = camel_folder_change_info_new();
+			folder_unmatched->changes = camel_folder_change_info_new ();
 		}
 
-		CAMEL_VEE_FOLDER_UNLOCK(folder_unmatched, summary_lock);
+		CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, summary_lock);
 	}
 
-	if (camel_folder_change_info_changed(vf->changes)) {
+	if (camel_folder_change_info_changed (vf->changes)) {
 		vf_changes = vf->changes;
-		vf->changes = camel_folder_change_info_new();
+		vf->changes = camel_folder_change_info_new ();
 	}
 
-	CAMEL_VEE_FOLDER_UNLOCK(vf, summary_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, summary_lock);
 
 	/* Del the unwanted things from the summary, we don't hold any locks now. */
 	if (del_list) {
 		if (!correlating) {
 			CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-			camel_db_delete_vuids(folder->parent_store->cdb_w, folder->full_name, shash, del_list, &ex);
+			camel_db_delete_vuids (folder->parent_store->cdb_w, folder->full_name, shash, del_list, &ex);
 			camel_exception_clear (&ex);
 		}
 		((CamelVeeSummary *)folder->summary)->force_counts = TRUE;
@@ -1302,27 +1301,27 @@ vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
 		g_slist_free (del_list);
 	};
 
-	g_hash_table_destroy(matchhash);
-	g_hash_table_destroy(allhash);
-	g_hash_table_destroy(fullhash);
+	g_hash_table_destroy (matchhash);
+	g_hash_table_destroy (allhash);
+	g_hash_table_destroy (fullhash);
 
-	g_free(shash);
+	g_free (shash);
 	/* if expression not set, we only had a null list */
 	if (vf->expression == NULL || !rebuilded) {
 		g_ptr_array_foreach (match, (GFunc) camel_pstring_free, NULL);
-		g_ptr_array_free(match, TRUE);
+		g_ptr_array_free (match, TRUE);
 	} else
-		camel_folder_search_free(source, match);
+		camel_folder_search_free (source, match);
 	camel_folder_free_summary (source, all);
 
 	if (unmatched_changes) {
-		camel_object_trigger_event((CamelObject *)folder_unmatched, "folder_changed", unmatched_changes);
-		camel_folder_change_info_free(unmatched_changes);
+		camel_object_trigger_event ((CamelObject *)folder_unmatched, "folder_changed", unmatched_changes);
+		camel_folder_change_info_free (unmatched_changes);
 	}
 
 	if (vf_changes) {
-		camel_object_trigger_event((CamelObject *)vf, "folder_changed", vf_changes);
-		camel_folder_change_info_free(vf_changes);
+		camel_object_trigger_event ((CamelObject *)vf, "folder_changed", vf_changes);
+		camel_folder_change_info_free (vf_changes);
 	}
 
 	return 0;
@@ -1330,7 +1329,7 @@ vee_rebuild_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException *ex)
 
 /* Hold all these with summary lock and unmatched summary lock held */
 static void
-folder_changed_add_uid(CamelFolder *sub, const gchar *uid, const gchar hash[8], CamelVeeFolder *vf, gboolean use_db)
+folder_changed_add_uid (CamelFolder *sub, const gchar *uid, const gchar hash[8], CamelVeeFolder *vf, gboolean use_db)
 {
 	CamelFolder *folder = (CamelFolder *)vf;
 	CamelVeeMessageInfo *vinfo;
@@ -1341,7 +1340,7 @@ folder_changed_add_uid(CamelFolder *sub, const gchar *uid, const gchar hash[8],
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 	GHashTable *unmatched_uids = vf->parent_vee_store ? vf->parent_vee_store->unmatched_uids : NULL;
 
-	vinfo = vee_folder_add_uid(vf, sub, uid, hash);
+	vinfo = vee_folder_add_uid (vf, sub, uid, hash);
 	if (vinfo == NULL)
 		return;
 
@@ -1352,21 +1351,21 @@ folder_changed_add_uid(CamelFolder *sub, const gchar *uid, const gchar hash[8],
 		camel_db_add_to_vfolder_transaction (folder->parent_store->cdb_w, folder->full_name, vuid, &ex);
 		camel_exception_clear (&ex);
 	}
-	camel_folder_change_info_add_uid(vf->changes,  vuid);
-	if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER(sub) && folder_unmatched != NULL) {
-		if (g_hash_table_lookup_extended(unmatched_uids, vuid, (gpointer *)&oldkey, &oldval)) {
+	camel_folder_change_info_add_uid (vf->changes,  vuid);
+	if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER (sub) && folder_unmatched != NULL) {
+		if (g_hash_table_lookup_extended (unmatched_uids, vuid, (gpointer *)&oldkey, &oldval)) {
 			n = GPOINTER_TO_INT (oldval);
-			g_hash_table_insert(unmatched_uids, oldkey, GINT_TO_POINTER(n+1));
+			g_hash_table_insert (unmatched_uids, oldkey, GINT_TO_POINTER (n+1));
 		} else {
-			g_hash_table_insert(unmatched_uids, g_strdup(vuid), GINT_TO_POINTER (1));
+			g_hash_table_insert (unmatched_uids, g_strdup (vuid), GINT_TO_POINTER (1));
 		}
-		vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info((CamelFolder *)folder_unmatched, vuid);
+		vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info ((CamelFolder *)folder_unmatched, vuid);
 		if (vinfo) {
 			CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-			camel_folder_change_info_remove_uid(folder_unmatched->changes, vuid);
+			camel_folder_change_info_remove_uid (folder_unmatched->changes, vuid);
 			camel_db_delete_uid_from_vfolder_transaction (folder->parent_store->cdb_w, ((CamelFolder *)folder_unmatched)->full_name, vuid, &ex);
-			camel_folder_summary_remove_uid_fast(((CamelFolder *)folder_unmatched)->summary, vuid);
-			camel_folder_free_message_info((CamelFolder *)folder_unmatched, (CamelMessageInfo *)vinfo);
+			camel_folder_summary_remove_uid_fast (((CamelFolder *)folder_unmatched)->summary, vuid);
+			camel_folder_free_message_info ((CamelFolder *)folder_unmatched, (CamelMessageInfo *)vinfo);
 			camel_exception_clear (&ex);
 		}
 	}
@@ -1375,7 +1374,7 @@ folder_changed_add_uid(CamelFolder *sub, const gchar *uid, const gchar hash[8],
 }
 
 static void
-folder_changed_remove_uid(CamelFolder *sub, const gchar *uid, const gchar hash[8], gint keep, CamelVeeFolder *vf, gboolean use_db)
+folder_changed_remove_uid (CamelFolder *sub, const gchar *uid, const gchar hash[8], gint keep, CamelVeeFolder *vf, gboolean use_db)
 {
 	CamelFolder *folder = (CamelFolder *)vf;
 	gchar *vuid, *oldkey;
@@ -1385,48 +1384,48 @@ folder_changed_remove_uid(CamelFolder *sub, const gchar *uid, const gchar hash[8
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 	GHashTable *unmatched_uids = vf->parent_vee_store ? vf->parent_vee_store->unmatched_uids : NULL;
 
-	vuid = alloca(strlen(uid)+9);
-	memcpy(vuid, hash, 8);
-	strcpy(vuid+8, uid);
+	vuid = alloca (strlen (uid)+9);
+	memcpy (vuid, hash, 8);
+	strcpy (vuid+8, uid);
 
-	camel_folder_change_info_remove_uid(vf->changes, vuid);
+	camel_folder_change_info_remove_uid (vf->changes, vuid);
 	if (use_db) {
 		/* FIXME[disk-summary] Handle exception */
 		CamelException ex = CAMEL_EXCEPTION_INITIALISER;
 		camel_db_delete_uid_from_vfolder_transaction (folder->parent_store->cdb_w, folder->full_name, vuid, &ex);
 		camel_exception_clear (&ex);
 	}
-	camel_folder_summary_remove_uid_fast(folder->summary, vuid);
+	camel_folder_summary_remove_uid_fast (folder->summary, vuid);
 
-	if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER(sub) && folder_unmatched != NULL) {
+	if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0 && !CAMEL_IS_VEE_FOLDER (sub) && folder_unmatched != NULL) {
 		if (keep) {
-			if (g_hash_table_lookup_extended(unmatched_uids, vuid, (gpointer *)&oldkey, &oldval)) {
+			if (g_hash_table_lookup_extended (unmatched_uids, vuid, (gpointer *)&oldkey, &oldval)) {
 				n = GPOINTER_TO_INT (oldval);
 				if (n == 1) {
-					g_hash_table_remove(unmatched_uids, oldkey);
+					g_hash_table_remove (unmatched_uids, oldkey);
 					if (vee_folder_add_uid_test (folder_unmatched, sub, uid, hash))
-						camel_folder_change_info_add_uid(folder_unmatched->changes, oldkey);
-					g_free(oldkey);
+						camel_folder_change_info_add_uid (folder_unmatched->changes, oldkey);
+					g_free (oldkey);
 				} else {
-					g_hash_table_insert(unmatched_uids, oldkey, GINT_TO_POINTER(n-1));
+					g_hash_table_insert (unmatched_uids, oldkey, GINT_TO_POINTER (n-1));
 				}
 			} else {
 				if (vee_folder_add_uid_test (folder_unmatched, sub, uid, hash))
-					camel_folder_change_info_add_uid(folder_unmatched->changes, oldkey);
+					camel_folder_change_info_add_uid (folder_unmatched->changes, oldkey);
 			}
 		} else {
-			if (g_hash_table_lookup_extended(unmatched_uids, vuid, (gpointer *)&oldkey, &oldval)) {
-				g_hash_table_remove(unmatched_uids, oldkey);
-				g_free(oldkey);
+			if (g_hash_table_lookup_extended (unmatched_uids, vuid, (gpointer *)&oldkey, &oldval)) {
+				g_hash_table_remove (unmatched_uids, oldkey);
+				g_free (oldkey);
 			}
 
-			vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info((CamelFolder *)folder_unmatched, vuid);
+			vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info ((CamelFolder *)folder_unmatched, vuid);
 			if (vinfo) {
 				CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-				camel_folder_change_info_remove_uid(folder_unmatched->changes, vuid);
+				camel_folder_change_info_remove_uid (folder_unmatched->changes, vuid);
 				camel_db_delete_uid_from_vfolder_transaction (folder->parent_store->cdb_w, ((CamelFolder *)folder_unmatched)->full_name, vuid, &ex);
-				camel_folder_summary_remove_uid_fast(((CamelFolder *)folder_unmatched)->summary, vuid);
-				camel_folder_free_message_info((CamelFolder *)folder_unmatched, (CamelMessageInfo *)vinfo);
+				camel_folder_summary_remove_uid_fast (((CamelFolder *)folder_unmatched)->summary, vuid);
+				camel_folder_free_message_info ((CamelFolder *)folder_unmatched, (CamelMessageInfo *)vinfo);
 				camel_exception_clear (&ex);
 			}
 		}
@@ -1434,7 +1433,7 @@ folder_changed_remove_uid(CamelFolder *sub, const gchar *uid, const gchar hash[8
 }
 
 static void
-folder_changed_change_uid(CamelFolder *sub, const gchar *uid, const gchar hash[8], CamelVeeFolder *vf, gboolean use_db)
+folder_changed_change_uid (CamelFolder *sub, const gchar *uid, const gchar hash[8], CamelVeeFolder *vf, gboolean use_db)
 {
 	gchar *vuid;
 	CamelVeeMessageInfo *vinfo, *uinfo = NULL;
@@ -1442,34 +1441,34 @@ folder_changed_change_uid(CamelFolder *sub, const gchar *uid, const gchar hash[8
 	CamelFolder *folder = (CamelFolder *)vf;
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 
-	vuid = alloca(strlen(uid)+9);
-	memcpy(vuid, hash, 8);
-	strcpy(vuid+8, uid);
+	vuid = alloca (strlen (uid)+9);
+	memcpy (vuid, hash, 8);
+	strcpy (vuid+8, uid);
 
-	vinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid(folder->summary, vuid);
+	vinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid (folder->summary, vuid);
 	if (folder_unmatched != NULL)
-		uinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid(((CamelFolder *)folder_unmatched)->summary, vuid);
+		uinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid (((CamelFolder *)folder_unmatched)->summary, vuid);
 	if (vinfo || uinfo) {
-		info = camel_folder_get_message_info(sub, uid);
+		info = camel_folder_get_message_info (sub, uid);
 		if (info) {
 			if (vinfo) {
-				camel_folder_change_info_change_uid(vf->changes, vuid);
-				camel_message_info_free((CamelMessageInfo *)vinfo);
+				camel_folder_change_info_change_uid (vf->changes, vuid);
+				camel_message_info_free ((CamelMessageInfo *)vinfo);
 			}
 
 			if (uinfo) {
-				camel_folder_change_info_change_uid(folder_unmatched->changes, vuid);
-				camel_message_info_free((CamelMessageInfo *)uinfo);
+				camel_folder_change_info_change_uid (folder_unmatched->changes, vuid);
+				camel_message_info_free ((CamelMessageInfo *)uinfo);
 			}
 
-			camel_folder_free_message_info(sub, info);
+			camel_folder_free_message_info (sub, info);
 		} else {
 			if (vinfo) {
-				folder_changed_remove_uid(sub, uid, hash, FALSE, vf, use_db);
-				camel_message_info_free((CamelMessageInfo *)vinfo);
+				folder_changed_remove_uid (sub, uid, hash, FALSE, vf, use_db);
+				camel_message_info_free ((CamelMessageInfo *)vinfo);
 			}
 			if (uinfo)
-				camel_message_info_free((CamelMessageInfo *)uinfo);
+				camel_message_info_free ((CamelMessageInfo *)uinfo);
 		}
 	}
 }
@@ -1482,7 +1481,7 @@ struct _folder_changed_msg {
 };
 
 static void
-folder_changed_change(CamelSession *session, CamelSessionThreadMsg *msg)
+folder_changed_change (CamelSession *session, CamelSessionThreadMsg *msg)
 {
 	struct _folder_changed_msg *m = (struct _folder_changed_msg *)msg;
 	CamelFolder *sub = m->sub;
@@ -1505,24 +1504,24 @@ folder_changed_change(CamelSession *session, CamelSessionThreadMsg *msg)
 	GPtrArray *present = NULL;
 
 	/* See vee_rebuild_folder. */
-	gboolean correlating = expression_is_correlating(vf->expression);
+	gboolean correlating = expression_is_correlating (vf->expression);
 
 	/* Check the folder hasn't beem removed while we weren't watching */
-	CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
-	if (g_list_find(_PRIVATE(vf)->folders, sub) == NULL) {
-		CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
+	if (g_list_find (_PRIVATE (vf)->folders, sub) == NULL) {
+		CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 		return;
 	}
 
-	camel_vee_folder_hash_folder(sub, hash);
+	camel_vee_folder_hash_folder (sub, hash);
 
 	/* Lookup anything before we lock anything, to avoid deadlock with build_folder */
 
 	/* Find newly added that match */
 	if (changes->uid_added->len > 0) {
 		CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-		dd(printf(" Searching for added matches '%s'\n", vf->expression));
-		matches_added = camel_folder_search_by_uids(sub, vf->expression, changes->uid_added, &ex);
+		dd (printf (" Searching for added matches '%s'\n", vf->expression));
+		matches_added = camel_folder_search_by_uids (sub, vf->expression, changes->uid_added, &ex);
 		camel_exception_clear (&ex);
 	}
 
@@ -1534,88 +1533,88 @@ folder_changed_change(CamelSession *session, CamelSessionThreadMsg *msg)
 	changed = changes->uid_changed;
 	if (changed->len > 0) {
 		CamelException ex = CAMEL_EXCEPTION_INITIALISER;
-		dd(printf(" Searching for changed matches '%s'\n", vf->expression));
+		dd (printf (" Searching for changed matches '%s'\n", vf->expression));
 
 		if ((vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO) == 0) {
-			newchanged = g_ptr_array_new();
-			always_changed = g_ptr_array_new();
+			newchanged = g_ptr_array_new ();
+			always_changed = g_ptr_array_new ();
 			for (i=0;i<changed->len;i++) {
 				uid = changed->pdata[i];
-				if (strlen(uid)+9 > vuidlen) {
-					vuidlen = strlen(uid)+64;
-					vuid = g_realloc(vuid, vuidlen);
+				if (strlen (uid)+9 > vuidlen) {
+					vuidlen = strlen (uid)+64;
+					vuid = g_realloc (vuid, vuidlen);
 				}
-				memcpy(vuid, hash, 8);
-				strcpy(vuid+8, uid);
-				vinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid(folder->summary, vuid);
+				memcpy (vuid, hash, 8);
+				strcpy (vuid+8, uid);
+				vinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid (folder->summary, vuid);
 				if (vinfo == NULL) {
-					g_ptr_array_add(newchanged, (gchar *)uid);
+					g_ptr_array_add (newchanged, (gchar *)uid);
 				} else {
-					g_ptr_array_add(always_changed, (gchar *)uid);
-					camel_message_info_free((CamelMessageInfo *)vinfo);
+					g_ptr_array_add (always_changed, (gchar *)uid);
+					camel_message_info_free ((CamelMessageInfo *)vinfo);
 				}
 			}
 			changed = newchanged;
 		}
 
 		if (changed->len)
-			matches_changed = camel_folder_search_by_uids(sub, vf->expression, changed, &ex);
+			matches_changed = camel_folder_search_by_uids (sub, vf->expression, changed, &ex);
 		camel_exception_clear (&ex);
 		if (always_changed && always_changed->len)
-			present = camel_folder_search_by_uids(sub, vf->expression, always_changed, &ex);
+			present = camel_folder_search_by_uids (sub, vf->expression, always_changed, &ex);
 		camel_exception_clear (&ex);
 	}
 
-	CAMEL_VEE_FOLDER_LOCK(vf, summary_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, summary_lock);
 
 	if (folder_unmatched != NULL)
-		CAMEL_VEE_FOLDER_LOCK(folder_unmatched, summary_lock);
+		CAMEL_VEE_FOLDER_LOCK (folder_unmatched, summary_lock);
 
 	if (matches_changed || matches_added || changes->uid_removed->len||present)
 		camel_db_begin_transaction (folder->parent_store->cdb_w, NULL);
 
-	dd(printf("Vfolder '%s' subfolder changed '%s'\n", folder->full_name, sub->full_name));
-	dd(printf(" changed %u added %u removed %u\n", changes->uid_changed->len, changes->uid_added->len, changes->uid_removed->len));
+	dd (printf ("Vfolder '%s' subfolder changed '%s'\n", folder->full_name, sub->full_name));
+	dd (printf (" changed %u added %u removed %u\n", changes->uid_changed->len, changes->uid_added->len, changes->uid_removed->len));
 
 	/* Always remove removed uid's, in any case */
 	for (i=0;i<changes->uid_removed->len;i++) {
-		dd(printf("  removing uid '%s'\n", (gchar *)changes->uid_removed->pdata[i]));
-		folder_changed_remove_uid(sub, changes->uid_removed->pdata[i], hash, FALSE, vf, !correlating);
+		dd (printf ("  removing uid '%s'\n", (gchar *)changes->uid_removed->pdata[i]));
+		folder_changed_remove_uid (sub, changes->uid_removed->pdata[i], hash, FALSE, vf, !correlating);
 	}
 
 	/* Add any newly matched or to unmatched folder if they dont */
 	if (matches_added) {
-		matches_hash = g_hash_table_new(g_str_hash, g_str_equal);
+		matches_hash = g_hash_table_new (g_str_hash, g_str_equal);
 		for (i=0;i<matches_added->len;i++) {
-			dd(printf(" %s", (gchar *)matches_added->pdata[i]));
-			g_hash_table_insert(matches_hash, matches_added->pdata[i], matches_added->pdata[i]);
+			dd (printf (" %s", (gchar *)matches_added->pdata[i]));
+			g_hash_table_insert (matches_hash, matches_added->pdata[i], matches_added->pdata[i]);
 		}
 		for (i=0;i<changes->uid_added->len;i++) {
 			uid = changes->uid_added->pdata[i];
-			if (g_hash_table_lookup(matches_hash, uid)) {
-				dd(printf("  adding uid '%s' [newly matched]\n", (gchar *)uid));
-				folder_changed_add_uid(sub, uid, hash, vf, !correlating);
+			if (g_hash_table_lookup (matches_hash, uid)) {
+				dd (printf ("  adding uid '%s' [newly matched]\n", (gchar *)uid));
+				folder_changed_add_uid (sub, uid, hash, vf, !correlating);
 			} else if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) {
-				if (strlen(uid)+9 > vuidlen) {
-					vuidlen = strlen(uid)+64;
-					vuid = g_realloc(vuid, vuidlen);
+				if (strlen (uid)+9 > vuidlen) {
+					vuidlen = strlen (uid)+64;
+					vuid = g_realloc (vuid, vuidlen);
 				}
-				memcpy(vuid, hash, 8);
-				strcpy(vuid+8, uid);
+				memcpy (vuid, hash, 8);
+				strcpy (vuid+8, uid);
 
-				if (!CAMEL_IS_VEE_FOLDER(sub) && folder_unmatched != NULL && g_hash_table_lookup(unmatched_uids, vuid) == NULL) {
-					dd(printf("  adding uid '%s' to Unmatched [newly unmatched]\n", (gchar *)uid));
-					vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info((CamelFolder *)folder_unmatched, vuid);
+				if (!CAMEL_IS_VEE_FOLDER (sub) && folder_unmatched != NULL && g_hash_table_lookup (unmatched_uids, vuid) == NULL) {
+					dd (printf ("  adding uid '%s' to Unmatched [newly unmatched]\n", (gchar *)uid));
+					vinfo = (CamelVeeMessageInfo *)camel_folder_get_message_info ((CamelFolder *)folder_unmatched, vuid);
 					if (vinfo == NULL) {
 						if (vee_folder_add_uid_test (folder_unmatched, sub, uid, hash))
-							camel_folder_change_info_add_uid(folder_unmatched->changes, vuid);
+							camel_folder_change_info_add_uid (folder_unmatched->changes, vuid);
 					} else {
-						camel_folder_free_message_info((CamelFolder *)folder_unmatched, (CamelMessageInfo *)vinfo);
+						camel_folder_free_message_info ((CamelFolder *)folder_unmatched, (CamelMessageInfo *)vinfo);
 					}
 				}
 			}
 		}
-		g_hash_table_destroy(matches_hash);
+		g_hash_table_destroy (matches_hash);
 	}
 
 	/* Change any newly changed */
@@ -1627,115 +1626,115 @@ folder_changed_change(CamelSession *session, CamelSessionThreadMsg *msg)
 			 * vee_rebuild_folder will make any necessary removals
 			 * when it re-queries the entire source folder. */
 			for (i=0;i<always_changed->len;i++)
-				folder_changed_change_uid(sub, always_changed->pdata[i], hash, vf, !correlating);
+				folder_changed_change_uid (sub, always_changed->pdata[i], hash, vf, !correlating);
 		} else {
 			GHashTable *ht_present = g_hash_table_new (g_str_hash, g_str_equal);
 
 			for (i=0;present && i<present->len;i++) {
-				folder_changed_change_uid(sub, present->pdata[i], hash, vf, !correlating);
+				folder_changed_change_uid (sub, present->pdata[i], hash, vf, !correlating);
 				g_hash_table_insert (ht_present, present->pdata[i], present->pdata[i]);
 			}
 
 			for (i=0; i<always_changed->len; i++) {
-				if (!present || !g_hash_table_lookup(ht_present, always_changed->pdata[i]))
+				if (!present || !g_hash_table_lookup (ht_present, always_changed->pdata[i]))
 					/* XXX: IIUC, these messages haven't been deleted from the
 					 * source folder, so shouldn't "keep" be set to TRUE? */
-					folder_changed_remove_uid(sub, always_changed->pdata[i], hash, TRUE, vf, !correlating);
+					folder_changed_remove_uid (sub, always_changed->pdata[i], hash, TRUE, vf, !correlating);
 			}
 
 			g_hash_table_destroy (ht_present);
 		}
-		g_ptr_array_free(always_changed, TRUE);
+		g_ptr_array_free (always_changed, TRUE);
 	}
 
 	/* Change/add/remove any changed */
 	if (changes->uid_changed->len) {
 		/* If we are auto-updating, then re-check changed uids still match */
-		dd(printf(" Vfolder %supdate\nuids match:", (vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO)?"auto-":""));
-		matches_hash = g_hash_table_new(g_str_hash, g_str_equal);
+		dd (printf (" Vfolder %supdate\nuids match:", (vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO)?"auto-":""));
+		matches_hash = g_hash_table_new (g_str_hash, g_str_equal);
 		for (i=0;matches_changed && i<matches_changed->len;i++) {
-			dd(printf(" %s", (gchar *)matches_changed->pdata[i]));
-			g_hash_table_insert(matches_hash, matches_changed->pdata[i], matches_changed->pdata[i]);
+			dd (printf (" %s", (gchar *)matches_changed->pdata[i]));
+			g_hash_table_insert (matches_hash, matches_changed->pdata[i], matches_changed->pdata[i]);
 		}
-		dd(printf("\n"));
+		dd (printf ("\n"));
 
 		for (i=0;i<changed->len;i++) {
 			uid = changed->pdata[i];
-			if (strlen(uid)+9 > vuidlen) {
-				vuidlen = strlen(uid)+64;
-				vuid = g_realloc(vuid, vuidlen);
+			if (strlen (uid)+9 > vuidlen) {
+				vuidlen = strlen (uid)+64;
+				vuid = g_realloc (vuid, vuidlen);
 			}
-			memcpy(vuid, hash, 8);
-			strcpy(vuid+8, uid);
-			vinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid(folder->summary, vuid);
+			memcpy (vuid, hash, 8);
+			strcpy (vuid+8, uid);
+			vinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid (folder->summary, vuid);
 			if (vinfo == NULL) {
-				if (g_hash_table_lookup(matches_hash, uid)) {
+				if (g_hash_table_lookup (matches_hash, uid)) {
 					/* A uid we dont have, but now it matches, add it */
-					dd(printf("  adding uid '%s' [newly matched]\n", uid));
-					folder_changed_add_uid(sub, uid, hash, vf, !correlating);
+					dd (printf ("  adding uid '%s' [newly matched]\n", uid));
+					folder_changed_add_uid (sub, uid, hash, vf, !correlating);
 				} else {
 					/* A uid we still don't have, just change it (for unmatched) */
-					folder_changed_change_uid(sub, uid, hash, vf, !correlating);
+					folder_changed_change_uid (sub, uid, hash, vf, !correlating);
 				}
 			} else {
 				if ((vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO) == 0
-				    || g_hash_table_lookup(matches_hash, uid)) {
+				    || g_hash_table_lookup (matches_hash, uid)) {
 					/* still match, or we're not auto-updating, change event, (if it changed) */
-					dd(printf("  changing uid '%s' [still matches]\n", uid));
-					folder_changed_change_uid(sub, uid, hash, vf, !correlating);
+					dd (printf ("  changing uid '%s' [still matches]\n", uid));
+					folder_changed_change_uid (sub, uid, hash, vf, !correlating);
 				} else {
 					/* No longer matches, remove it, but keep it in unmatched (potentially) */
-					dd(printf("  removing uid '%s' [did match]\n", uid));
-					folder_changed_remove_uid(sub, uid, hash, TRUE, vf, !correlating);
+					dd (printf ("  removing uid '%s' [did match]\n", uid));
+					folder_changed_remove_uid (sub, uid, hash, TRUE, vf, !correlating);
 				}
-				camel_message_info_free((CamelMessageInfo *)vinfo);
+				camel_message_info_free ((CamelMessageInfo *)vinfo);
 			}
 		}
-		g_hash_table_destroy(matches_hash);
+		g_hash_table_destroy (matches_hash);
 	} else {
 		/* stuff didn't match but it changed - check unmatched folder for changes */
 		for (i=0;i<changed->len;i++)
-			folder_changed_change_uid(sub, changed->pdata[i], hash, vf, !correlating);
+			folder_changed_change_uid (sub, changed->pdata[i], hash, vf, !correlating);
 	}
 
 	if (folder_unmatched != NULL) {
-		if (camel_folder_change_info_changed(folder_unmatched->changes)) {
+		if (camel_folder_change_info_changed (folder_unmatched->changes)) {
 			unmatched_changes = folder_unmatched->changes;
-			folder_unmatched->changes = camel_folder_change_info_new();
+			folder_unmatched->changes = camel_folder_change_info_new ();
 		}
 
-		CAMEL_VEE_FOLDER_UNLOCK(folder_unmatched, summary_lock);
+		CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, summary_lock);
 	}
 
-	if (camel_folder_change_info_changed(vf->changes)) {
+	if (camel_folder_change_info_changed (vf->changes)) {
 		vf_changes = vf->changes;
-		vf->changes = camel_folder_change_info_new();
+		vf->changes = camel_folder_change_info_new ();
 	}
 
 	if (matches_changed || matches_added || changes->uid_removed->len || present)
 		camel_db_end_transaction (folder->parent_store->cdb_w, NULL);
-	CAMEL_VEE_FOLDER_UNLOCK(vf, summary_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, summary_lock);
 
 	/* Cleanup stuff on our folder */
 	if (matches_added)
-		camel_folder_search_free(sub, matches_added);
+		camel_folder_search_free (sub, matches_added);
 	if (present)
 		camel_folder_search_free (sub, present);
 
 	if (matches_changed)
-		camel_folder_search_free(sub, matches_changed);
+		camel_folder_search_free (sub, matches_changed);
 
-	CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 
 	/* cleanup the rest */
 	if (newchanged)
-		g_ptr_array_free(newchanged, TRUE);
+		g_ptr_array_free (newchanged, TRUE);
 
-	g_free(vuid);
+	g_free (vuid);
 
 	if (unmatched_changes) {
-		camel_object_trigger_event((CamelObject *)folder_unmatched, "folder_changed", unmatched_changes);
-		camel_folder_change_info_free(unmatched_changes);
+		camel_object_trigger_event ((CamelObject *)folder_unmatched, "folder_changed", unmatched_changes);
+		camel_folder_change_info_free (unmatched_changes);
 	}
 
 	/* Add to folders_changed if we need to call vee_rebuild_folder, which
@@ -1750,26 +1749,26 @@ folder_changed_change(CamelSession *session, CamelSessionThreadMsg *msg)
 	 *   rather be safe than sorry.)
 	 */
 	if ((vf_changes && (vf->flags & CAMEL_STORE_VEE_FOLDER_AUTO) == 0) || correlating) {
-		CAMEL_VEE_FOLDER_LOCK(vf, changed_lock);
-		if (g_list_find(vf->priv->folders_changed, sub) == NULL)
-			vf->priv->folders_changed = g_list_prepend(vf->priv->folders_changed, sub);
-		CAMEL_VEE_FOLDER_UNLOCK(vf, changed_lock);
+		CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+		if (g_list_find (vf->priv->folders_changed, sub) == NULL)
+			vf->priv->folders_changed = g_list_prepend (vf->priv->folders_changed, sub);
+		CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
 	}
 
 	if (vf_changes) {
-		camel_object_trigger_event((CamelObject *)vf, "folder_changed", vf_changes);
-		camel_folder_change_info_free(vf_changes);
+		camel_object_trigger_event ((CamelObject *)vf, "folder_changed", vf_changes);
+		camel_folder_change_info_free (vf_changes);
 	}
 }
 
 static void
-folder_changed_free(CamelSession *session, CamelSessionThreadMsg *msg)
+folder_changed_free (CamelSession *session, CamelSessionThreadMsg *msg)
 {
 	struct _folder_changed_msg *m = (struct _folder_changed_msg *)msg;
 
-	camel_folder_change_info_free(m->changes);
-	camel_object_unref((CamelObject *)m->vf);
-	camel_object_unref((CamelObject *)m->sub);
+	camel_folder_change_info_free (m->changes);
+	camel_object_unref (m->vf);
+	camel_object_unref (m->sub);
 }
 
 static CamelSessionThreadOps folder_changed_ops = {
@@ -1778,40 +1777,38 @@ static CamelSessionThreadOps folder_changed_ops = {
 };
 
 static void
-folder_changed_base(CamelVeeFolder *vf, CamelFolder *sub, CamelFolderChangeInfo *changes)
+folder_changed_base (CamelVeeFolder *vf, CamelFolder *sub, CamelFolderChangeInfo *changes)
 {
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
 	struct _folder_changed_msg *m;
 	CamelSession *session = ((CamelService *)((CamelFolder *)vf)->parent_store)->session;
 
 	if (p->destroyed)
 		return;
 
-	m = camel_session_thread_msg_new(session, &folder_changed_ops, sizeof(*m));
-	m->changes = camel_folder_change_info_new();
-	camel_folder_change_info_cat(m->changes, changes);
-	m->sub = sub;
-	camel_object_ref((CamelObject *)sub);
-	m->vf = vf;
-	camel_object_ref((CamelObject *)vf);
-	camel_session_thread_queue(session, &m->msg, 0);
+	m = camel_session_thread_msg_new (session, &folder_changed_ops, sizeof (*m));
+	m->changes = camel_folder_change_info_new ();
+	camel_folder_change_info_cat (m->changes, changes);
+	m->sub = camel_object_ref (sub);
+	m->vf = camel_object_ref (vf);
+	camel_session_thread_queue (session, &m->msg, 0);
 }
 
 static void
-folder_changed(CamelFolder *sub, CamelFolderChangeInfo *changes, CamelVeeFolder *vf)
+folder_changed (CamelFolder *sub, CamelFolderChangeInfo *changes, CamelVeeFolder *vf)
 {
-	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->folder_changed(vf, sub, changes);
+	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->folder_changed (vf, sub, changes);
 }
 
 /* track vanishing folders */
 static void
-subfolder_deleted(CamelFolder *f, gpointer event_data, CamelVeeFolder *vf)
+subfolder_deleted (CamelFolder *f, gpointer event_data, CamelVeeFolder *vf)
 {
-	camel_vee_folder_remove_folder(vf, f);
+	camel_vee_folder_remove_folder (vf, f);
 }
 
 static void
-subfolder_renamed_update(CamelVeeFolder *vf, CamelFolder *sub, gchar hash[8])
+subfolder_renamed_update (CamelVeeFolder *vf, CamelFolder *sub, gchar hash[8])
 {
 	gint count, i;
 	CamelFolderChangeInfo *changes = NULL;
@@ -1819,62 +1816,62 @@ subfolder_renamed_update(CamelVeeFolder *vf, CamelFolder *sub, gchar hash[8])
 	GHashTable *unmatched_uids = vf->parent_vee_store ? vf->parent_vee_store->unmatched_uids : NULL;
 	CamelFolderSummary *ssummary = sub->summary;
 
-	CAMEL_VEE_FOLDER_LOCK(vf, summary_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, summary_lock);
 
-	count = camel_folder_summary_count(((CamelFolder *)vf)->summary);
+	count = camel_folder_summary_count (((CamelFolder *)vf)->summary);
 	for (i=0;i<count;i++) {
-		CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index(((CamelFolder *)vf)->summary, i);
+		CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index (((CamelFolder *)vf)->summary, i);
 		CamelVeeMessageInfo *vinfo;
 
 		if (mi == NULL)
 			continue;
 
 		if (mi->summary == ssummary) {
-			gchar *uid = (gchar *)camel_message_info_uid(mi);
+			gchar *uid = (gchar *)camel_message_info_uid (mi);
 			gchar *oldkey;
 			gpointer oldval;
 
-			camel_folder_change_info_remove_uid(vf->changes, uid);
-			camel_folder_summary_remove(((CamelFolder *)vf)->summary, (CamelMessageInfo *)mi);
+			camel_folder_change_info_remove_uid (vf->changes, uid);
+			camel_folder_summary_remove (((CamelFolder *)vf)->summary, (CamelMessageInfo *)mi);
 
 			/* works since we always append on the end */
 			i--;
 			count--;
 
-			vinfo = vee_folder_add_uid(vf, sub, uid+8, hash);
+			vinfo = vee_folder_add_uid (vf, sub, uid+8, hash);
 			if (vinfo) {
-				camel_folder_change_info_add_uid(vf->changes, camel_message_info_uid(vinfo));
+				camel_folder_change_info_add_uid (vf->changes, camel_message_info_uid (vinfo));
 
 				/* check unmatched uid's table for any matches */
 				if (vf == folder_unmatched
-				    && g_hash_table_lookup_extended(unmatched_uids, uid, (gpointer *)&oldkey, &oldval)) {
-					g_hash_table_remove(unmatched_uids, oldkey);
-					g_hash_table_insert(unmatched_uids, g_strdup(camel_message_info_uid(vinfo)), oldval);
-					g_free(oldkey);
+				    && g_hash_table_lookup_extended (unmatched_uids, uid, (gpointer *)&oldkey, &oldval)) {
+					g_hash_table_remove (unmatched_uids, oldkey);
+					g_hash_table_insert (unmatched_uids, g_strdup (camel_message_info_uid (vinfo)), oldval);
+					g_free (oldkey);
 				}
 
 				camel_message_info_free ((CamelMessageInfo *) vinfo);
 			}
 		}
 
-		camel_message_info_free((CamelMessageInfo *)mi);
+		camel_message_info_free ((CamelMessageInfo *)mi);
 	}
 
-	if (camel_folder_change_info_changed(vf->changes)) {
+	if (camel_folder_change_info_changed (vf->changes)) {
 		changes = vf->changes;
-		vf->changes = camel_folder_change_info_new();
+		vf->changes = camel_folder_change_info_new ();
 	}
 
-	CAMEL_VEE_FOLDER_UNLOCK(vf, summary_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, summary_lock);
 
 	if (changes) {
-		camel_object_trigger_event((CamelObject *)vf, "folder_changed", changes);
-		camel_folder_change_info_free(changes);
+		camel_object_trigger_event ((CamelObject *)vf, "folder_changed", changes);
+		camel_folder_change_info_free (changes);
 	}
 }
 
 static void
-folder_renamed_base(CamelVeeFolder *vf, CamelFolder *f, const gchar *old)
+folder_renamed_base (CamelVeeFolder *vf, CamelFolder *f, const gchar *old)
 {
 	gchar hash[8];
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
@@ -1884,68 +1881,68 @@ folder_renamed_base(CamelVeeFolder *vf, CamelFolder *f, const gchar *old)
 	/* Life just got that little bit harder, if the folder is renamed, it means it breaks all of our uid's.
 	   We need to remove the old uid's, fix them up, then release the new uid's, for the uid's that match this folder */
 
-	camel_vee_folder_hash_folder(f, hash);
+	camel_vee_folder_hash_folder (f, hash);
 
-	subfolder_renamed_update(vf, f, hash);
+	subfolder_renamed_update (vf, f, hash);
 	if (folder_unmatched != NULL)
-		subfolder_renamed_update(folder_unmatched, f, hash);
+		subfolder_renamed_update (folder_unmatched, f, hash);
 }
 
 static void
-folder_renamed(CamelFolder *sub, const gchar *old, CamelVeeFolder *vf)
+folder_renamed (CamelFolder *sub, const gchar *old, CamelVeeFolder *vf)
 {
-	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->folder_renamed(vf, sub, old);
+	((CamelVeeFolderClass *)((CamelObject *)vf)->klass)->folder_renamed (vf, sub, old);
 }
 
 static void
 vee_freeze (CamelFolder *folder)
 {
 	CamelVeeFolder *vfolder = (CamelVeeFolder *)folder;
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vfolder);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vfolder);
 	GList *node;
 
-	CAMEL_VEE_FOLDER_LOCK(vfolder, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vfolder, subfolder_lock);
 
 	node = p->folders;
 	while (node) {
 		CamelFolder *f = node->data;
 
-		camel_folder_freeze(f);
+		camel_folder_freeze (f);
 		node = node->next;
 	}
 
-	CAMEL_VEE_FOLDER_UNLOCK(vfolder, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vfolder, subfolder_lock);
 
 	/* call parent implementation */
-	CAMEL_FOLDER_CLASS (camel_vee_folder_parent)->freeze(folder);
+	CAMEL_FOLDER_CLASS (camel_vee_folder_parent)->freeze (folder);
 }
 
 static void
-vee_thaw(CamelFolder *folder)
+vee_thaw (CamelFolder *folder)
 {
 	CamelVeeFolder *vfolder = (CamelVeeFolder *)folder;
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vfolder);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vfolder);
 	GList *node;
 
-	CAMEL_VEE_FOLDER_LOCK(vfolder, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vfolder, subfolder_lock);
 
 	node = p->folders;
 	while (node) {
 		CamelFolder *f = node->data;
 
-		camel_folder_thaw(f);
+		camel_folder_thaw (f);
 		node = node->next;
 	}
 
-	CAMEL_VEE_FOLDER_UNLOCK(vfolder, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vfolder, subfolder_lock);
 
 	/* call parent implementation */
-	CAMEL_FOLDER_CLASS (camel_vee_folder_parent)->thaw(folder);
+	CAMEL_FOLDER_CLASS (camel_vee_folder_parent)->thaw (folder);
 }
 
 /* vfolder base implementaitons */
 static void
-vee_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
+vee_add_folder (CamelVeeFolder *vf, CamelFolder *sub)
 {
 	CamelException ex = CAMEL_EXCEPTION_INITIALISER;
 
@@ -1955,14 +1952,14 @@ vee_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
 }
 
 static void
-vee_remove_folder(CamelVeeFolder *vf, CamelFolder *sub)
+vee_remove_folder (CamelVeeFolder *vf, CamelFolder *sub)
 {
 	gchar *shash, hash[8];
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 
-	camel_vee_folder_hash_folder(sub, hash);
-	vee_folder_remove_folder(vf, sub);
-	shash = g_strdup_printf("%c%c%c%c%c%c%c%c", hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7]);
+	camel_vee_folder_hash_folder (sub, hash);
+	vee_folder_remove_folder (vf, sub);
+	shash = g_strdup_printf ("%c%c%c%c%c%c%c%c", hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7]);
 	if (g_hash_table_lookup (vf->hashes, shash)) {
 		g_hash_table_remove (vf->hashes, shash);
 	}
@@ -1971,23 +1968,23 @@ vee_remove_folder(CamelVeeFolder *vf, CamelFolder *sub)
 		g_hash_table_remove (folder_unmatched->hashes, shash);
 	}
 
-	g_free(shash);
+	g_free (shash);
 
 }
 
 static void
-vee_set_expression(CamelVeeFolder *vf, const gchar *query)
+vee_set_expression (CamelVeeFolder *vf, const gchar *query)
 {
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
 	GList *node;
 	CamelException ex = CAMEL_EXCEPTION_INITIALISER;
 
-	CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
 
 	/* no change, do nothing */
-	if ((vf->expression && query && strcmp(vf->expression, query) == 0)
+	if ((vf->expression && query && strcmp (vf->expression, query) == 0)
 	    || (vf->expression == NULL && query == NULL)) {
-		CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+		CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 		return;
 	}
 
@@ -2004,9 +2001,9 @@ vee_set_expression(CamelVeeFolder *vf, const gchar *query)
 		s->junk_not_deleted_count = 0;
 	}
 
-	g_free(vf->expression);
+	g_free (vf->expression);
 	if (query)
-		vf->expression = g_strdup(query);
+		vf->expression = g_strdup (query);
 
 	node = p->folders;
 	while (node) {
@@ -2022,17 +2019,17 @@ vee_set_expression(CamelVeeFolder *vf, const gchar *query)
 
 	camel_exception_clear (&ex);
 
-	CAMEL_VEE_FOLDER_LOCK(vf, changed_lock);
-	g_list_free(p->folders_changed);
+	CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+	g_list_free (p->folders_changed);
 	p->folders_changed = NULL;
-	CAMEL_VEE_FOLDER_UNLOCK(vf, changed_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
 
-	CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 }
 
 /* This entire code will be useless, since we sync the counts always. */
 static gint
-vf_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
+vf_getv (CamelObject *object, CamelException *ex, CamelArgGetV *args)
 {
 	CamelFolder *folder = (CamelFolder *)object;
 	CamelVeeFolder *vf = (CamelVeeFolder *)folder;
@@ -2064,13 +2061,13 @@ vf_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 				CamelVeeMessageInfo *vinfo;
 
 				unread = deleted = visible = junked = junked_not_deleted = 0;
-				count = camel_folder_summary_count(folder->summary);
+				count = camel_folder_summary_count (folder->summary);
 				for (j=0; j<count; j++) {
-					if ((info = (CamelMessageInfoBase *) camel_folder_summary_index(folder->summary, j))) {
+					if ((info = (CamelMessageInfoBase *) camel_folder_summary_index (folder->summary, j))) {
 						guint32 flags;
 
 						vinfo = (CamelVeeMessageInfo *) info;
-						flags = vinfo->old_flags; /* ? vinfo->old_flags : camel_message_info_flags(info); */
+						flags = vinfo->old_flags; /* ? vinfo->old_flags : camel_message_info_flags (info); */
 
 						if ((flags & (CAMEL_MESSAGE_SEEN)) == 0)
 							unread++;
@@ -2083,7 +2080,7 @@ vf_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 						}
 						if ((flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
 							visible++;
-						camel_message_info_free(info);
+						camel_message_info_free (info);
 					}
 				}
 			}
@@ -2126,7 +2123,7 @@ vf_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 		arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
 	}
 
-	return ((CamelObjectClass *)camel_vee_folder_parent)->getv(object, ex, args);
+	return ((CamelObjectClass *)camel_vee_folder_parent)->getv (object, ex, args);
 }
 
 static void
@@ -2134,7 +2131,7 @@ camel_vee_folder_class_init (CamelVeeFolderClass *klass)
 {
 	CamelFolderClass *folder_class = (CamelFolderClass *) klass;
 
-	camel_vee_folder_parent = CAMEL_FOLDER_CLASS(camel_type_get_global_classfuncs (camel_folder_get_type ()));
+	camel_vee_folder_parent = CAMEL_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_folder_get_type ()));
 
 	((CamelObjectClass *)klass)->getv = vf_getv;
 
@@ -2170,7 +2167,7 @@ camel_vee_folder_init (CamelVeeFolder *obj)
 	struct _CamelVeeFolderPrivate *p;
 	CamelFolder *folder = (CamelFolder *)obj;
 
-	p = _PRIVATE(obj) = g_malloc0(sizeof(*p));
+	p = _PRIVATE (obj) = g_malloc0 (sizeof (*p));
 
 	folder->folder_flags |= (CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY |
 				 CAMEL_FOLDER_HAS_SEARCH_CAPABILITY);
@@ -2182,15 +2179,15 @@ camel_vee_folder_init (CamelVeeFolder *obj)
 		CAMEL_MESSAGE_FLAGGED |
 		CAMEL_MESSAGE_SEEN;
 
-	obj->changes = camel_folder_change_info_new();
-	obj->search = camel_folder_search_new();
+	obj->changes = camel_folder_change_info_new ();
+	obj->search = camel_folder_search_new ();
 	obj->hashes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 	/* Loaded is no longer used.*/
 	obj->loaded = NULL;
 	obj->deleted = FALSE;
-	p->summary_lock = g_mutex_new();
-	p->subfolder_lock = g_mutex_new();
-	p->changed_lock = g_mutex_new();
+	p->summary_lock = g_mutex_new ();
+	p->subfolder_lock = g_mutex_new ();
+	p->changed_lock = g_mutex_new ();
 	p->unread_vfolder = -1;
 }
 
@@ -2202,7 +2199,7 @@ camel_vee_folder_init (CamelVeeFolder *obj)
 void
 camel_vee_folder_mask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *sub)
 {
-	camel_object_unhook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
+	camel_object_unhook_event ((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
 
 }
 
@@ -2214,76 +2211,76 @@ camel_vee_folder_mask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *sub
 void
 camel_vee_folder_unmask_event_folder_changed (CamelVeeFolder *vf, CamelFolder *sub)
 {
-	camel_object_hook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
+	camel_object_hook_event ((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
 }
 
 static void
-vee_folder_stop_folder(CamelVeeFolder *vf, CamelFolder *sub)
+vee_folder_stop_folder (CamelVeeFolder *vf, CamelFolder *sub)
 {
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
 	gint i;
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 
-	CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, subfolder_lock);
 
-	CAMEL_VEE_FOLDER_LOCK(vf, changed_lock);
-	p->folders_changed = g_list_remove(p->folders_changed, sub);
-	CAMEL_VEE_FOLDER_UNLOCK(vf, changed_lock);
+	CAMEL_VEE_FOLDER_LOCK (vf, changed_lock);
+	p->folders_changed = g_list_remove (p->folders_changed, sub);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, changed_lock);
 
-	if (g_list_find(p->folders, sub) == NULL) {
-		CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	if (g_list_find (p->folders, sub) == NULL) {
+		CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 		return;
 	}
 
-	camel_object_unhook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
-	camel_object_unhook_event((CamelObject *)sub, "deleted", (CamelObjectEventHookFunc) subfolder_deleted, vf);
-	camel_object_unhook_event((CamelObject *)sub, "renamed", (CamelObjectEventHookFunc) folder_renamed, vf);
+	camel_object_unhook_event ((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf);
+	camel_object_unhook_event ((CamelObject *)sub, "deleted", (CamelObjectEventHookFunc) subfolder_deleted, vf);
+	camel_object_unhook_event ((CamelObject *)sub, "renamed", (CamelObjectEventHookFunc) folder_renamed, vf);
 
-	p->folders = g_list_remove(p->folders, sub);
+	p->folders = g_list_remove (p->folders, sub);
 
 	/* undo the freeze state that we have imposed on this source folder */
-	CAMEL_FOLDER_LOCK(vf, change_lock);
+	CAMEL_FOLDER_LOCK (vf, change_lock);
 	for (i = 0; i < ((CamelFolder *)vf)->priv->frozen; i++)
-		camel_folder_thaw(sub);
-	CAMEL_FOLDER_UNLOCK(vf, change_lock);
+		camel_folder_thaw (sub);
+	CAMEL_FOLDER_UNLOCK (vf, change_lock);
 
-	CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock);
+	CAMEL_VEE_FOLDER_UNLOCK (vf, subfolder_lock);
 
 	if (folder_unmatched != NULL) {
-		struct _CamelVeeFolderPrivate *up = _PRIVATE(folder_unmatched);
+		struct _CamelVeeFolderPrivate *up = _PRIVATE (folder_unmatched);
 
-		CAMEL_VEE_FOLDER_LOCK(folder_unmatched, subfolder_lock);
+		CAMEL_VEE_FOLDER_LOCK (folder_unmatched, subfolder_lock);
 		/* if folder deleted, then blow it away from unmatched always, and remove all refs to it */
 		if (sub->folder_flags & CAMEL_FOLDER_HAS_BEEN_DELETED) {
-			while (g_list_find(up->folders, sub)) {
-				up->folders = g_list_remove(up->folders, sub);
-				camel_object_unref((CamelObject *)sub);
+			while (g_list_find (up->folders, sub)) {
+				up->folders = g_list_remove (up->folders, sub);
+				camel_object_unref (sub);
 
 				/* undo the freeze state that Unmatched has imposed on this source folder */
-				CAMEL_FOLDER_LOCK(folder_unmatched, change_lock);
+				CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
 				for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
-					camel_folder_thaw(sub);
-				CAMEL_FOLDER_UNLOCK(folder_unmatched, change_lock);
+					camel_folder_thaw (sub);
+				CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
 			}
 		} else if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) {
-			if (g_list_find(up->folders, sub) != NULL) {
-				up->folders = g_list_remove(up->folders, sub);
-				camel_object_unref((CamelObject *)sub);
+			if (g_list_find (up->folders, sub) != NULL) {
+				up->folders = g_list_remove (up->folders, sub);
+				camel_object_unref (sub);
 
 				/* undo the freeze state that Unmatched has imposed on this source folder */
-				CAMEL_FOLDER_LOCK(folder_unmatched, change_lock);
+				CAMEL_FOLDER_LOCK (folder_unmatched, change_lock);
 				for (i = 0; i < ((CamelFolder *)folder_unmatched)->priv->frozen; i++)
-					camel_folder_thaw(sub);
-				CAMEL_FOLDER_UNLOCK(folder_unmatched, change_lock);
+					camel_folder_thaw (sub);
+				CAMEL_FOLDER_UNLOCK (folder_unmatched, change_lock);
 			}
 		}
-		CAMEL_VEE_FOLDER_UNLOCK(folder_unmatched, subfolder_lock);
+		CAMEL_VEE_FOLDER_UNLOCK (folder_unmatched, subfolder_lock);
 	}
 
-	if (CAMEL_IS_VEE_FOLDER(sub))
+	if (CAMEL_IS_VEE_FOLDER (sub))
 		return;
 
-	camel_object_unref((CamelObject *)sub);
+	camel_object_unref (sub);
 }
 
 /**
@@ -2298,11 +2295,11 @@ camel_vee_folder_sync_headers (CamelFolder *vf, CamelException *ex)
 	time_t start, end;
 
 	/* Save the counts to DB */
-	start = time(NULL);
+	start = time (NULL);
 	record = summary_header_to_db (vf->summary, ex);
 	camel_db_write_folder_info_record (vf->parent_store->cdb_w, record, ex);
-	end = time(NULL);
-	dd(printf("Sync for vfolder '%s': %ld secs\n", vf->full_name, end-start));
+	end = time (NULL);
+	dd (printf ("Sync for vfolder '%s': %ld secs\n", vf->full_name, end-start));
 
 	g_free (record);
 }
@@ -2311,7 +2308,7 @@ static void
 camel_vee_folder_finalize (CamelObject *obj)
 {
 	CamelVeeFolder *vf = (CamelVeeFolder *)obj;
-	struct _CamelVeeFolderPrivate *p = _PRIVATE(vf);
+	struct _CamelVeeFolderPrivate *p = _PRIVATE (vf);
 	CamelVeeFolder *folder_unmatched = vf->parent_vee_store ? vf->parent_vee_store->folder_unmatched : NULL;
 	GList *node;
 	CamelFIRecord * record;
@@ -2329,29 +2326,29 @@ camel_vee_folder_finalize (CamelObject *obj)
 
 	/* This may invoke sub-classes with partially destroyed state, they must deal with this */
 	if (vf == folder_unmatched) {
-		for (node = p->folders;node;node = g_list_next(node))
-			camel_object_unref(node->data);
+		for (node = p->folders;node;node = g_list_next (node))
+			camel_object_unref (node->data);
 	} else {
 		/* FIXME[disk-summary] See if it is really reqd */
 		camel_folder_freeze ((CamelFolder *)vf);
 		while (p->folders) {
 			CamelFolder *f = p->folders->data;
-			vee_folder_stop_folder(vf, f);
+			vee_folder_stop_folder (vf, f);
 		}
 		camel_folder_thaw ((CamelFolder *)vf);
 	}
 
-	g_free(vf->expression);
+	g_free (vf->expression);
 
-	g_list_free(p->folders);
-	g_list_free(p->folders_changed);
+	g_list_free (p->folders);
+	g_list_free (p->folders_changed);
 
-	camel_folder_change_info_free(vf->changes);
-	camel_object_unref((CamelObject *)vf->search);
+	camel_folder_change_info_free (vf->changes);
+	camel_object_unref (vf->search);
 
-	g_mutex_free(p->summary_lock);
-	g_mutex_free(p->subfolder_lock);
-	g_mutex_free(p->changed_lock);
+	g_mutex_free (p->summary_lock);
+	g_mutex_free (p->subfolder_lock);
+	g_mutex_free (p->changed_lock);
 	g_hash_table_destroy (vf->hashes);
-	g_free(p);
+	g_free (p);
 }
diff --git a/camel/camel-vee-store.c b/camel/camel-vee-store.c
index 7c51996..93fe301 100644
--- a/camel/camel-vee-store.c
+++ b/camel/camel-vee-store.c
@@ -24,7 +24,6 @@
 
 #include <string.h>
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
 
@@ -37,220 +36,235 @@
 
 #define d(x)
 
-static CamelFolder *vee_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex);
-static void vee_delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex);
-static void vee_rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex);
-
-static CamelFolder *vee_get_trash  (CamelStore *store, CamelException *ex);
-static CamelFolder *vee_get_junk  (CamelStore *store, CamelException *ex);
-
-static CamelFolderInfo *vee_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex);
-
-static void camel_vee_store_class_init (CamelVeeStoreClass *klass);
-static void camel_vee_store_init       (CamelVeeStore *obj);
-static void camel_vee_store_finalize   (CamelObject *obj);
-
-static gchar *vee_get_name (CamelService *service, gboolean brief);
-static void vee_construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex);
+/* flags
+   1 = delete (0 = add)
+   2 = noselect
+*/
+#define CHANGE_ADD (0)
+#define CHANGE_DELETE (1)
+#define CHANGE_NOSELECT (2)
 
 static CamelStoreClass *camel_vee_store_parent;
 
-CamelType
-camel_vee_store_get_type (void)
+static gint
+vee_folder_cmp (gconstpointer ap,
+                gconstpointer bp)
 {
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register (camel_store_get_type (), "CamelVeeStore",
-					    sizeof (CamelVeeStore),
-					    sizeof (CamelVeeStoreClass),
-					    (CamelObjectClassInitFunc) camel_vee_store_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_vee_store_init,
-					    (CamelObjectFinalizeFunc) camel_vee_store_finalize);
-	}
-
-	return type;
+	return strcmp (((CamelFolder **)ap)[0]->full_name, ((CamelFolder **)bp)[0]->full_name);
 }
 
 static void
-camel_vee_store_class_init (CamelVeeStoreClass *klass)
+change_folder (CamelStore *store,
+               const gchar *name,
+               guint32 flags,
+               gint count)
 {
-	CamelStoreClass *store_class = (CamelStoreClass *) klass;
-
-	camel_vee_store_parent = (CamelStoreClass *)camel_store_get_type();
-
-	/* virtual method overload */
-	store_class->get_folder = vee_get_folder;
-	store_class->rename_folder = vee_rename_folder;
-	store_class->delete_folder = vee_delete_folder;
-	store_class->get_folder_info = vee_get_folder_info;
-	store_class->free_folder_info = camel_store_free_folder_info_full;
-
-	((CamelServiceClass *)store_class)->construct = vee_construct;
-	((CamelServiceClass *)store_class)->get_name = vee_get_name;
+	CamelFolderInfo *fi;
+	const gchar *tmp;
+	CamelURL *url;
 
-	store_class->get_trash = vee_get_trash;
-	store_class->get_junk = vee_get_junk;
+	fi = camel_folder_info_new ();
+	fi->full_name = g_strdup (name);
+	tmp = strrchr (name, '/');
+	if (tmp == NULL)
+		tmp = name;
+	else
+		tmp++;
+	fi->name = g_strdup (tmp);
+	url = camel_url_new ("vfolder:", NULL);
+	camel_url_set_path (url, ((CamelService *)store)->url->path);
+	if (flags & CHANGE_NOSELECT)
+		camel_url_set_param (url, "noselect", "yes");
+	camel_url_set_fragment (url, name);
+	fi->uri = camel_url_to_string (url, 0);
+	camel_url_free (url);
+	/*fi->url = g_strdup_printf ("vfolder:%s%s#%s", ((CamelService *)store)->url->path, (flags&CHANGE_NOSELECT)?";noselect=yes":"", name);*/
+	fi->unread = count;
+	fi->flags = CAMEL_FOLDER_VIRTUAL;
+	if (!(flags & CHANGE_DELETE))
+		fi->flags |= CAMEL_FOLDER_NOCHILDREN;
+	camel_object_trigger_event (store, (flags&CHANGE_DELETE)?"folder_deleted":"folder_created", fi);
+	camel_folder_info_free (fi);
 }
 
 static void
-camel_vee_store_init (CamelVeeStore *obj)
+cvs_free_unmatched (gpointer key, gpointer value, gpointer data)
 {
-	CamelStore *store = (CamelStore *)obj;
+	g_free (key);
+}
 
-	/* we dont want a vtrash/vjunk on this one */
-	store->flags &= ~(CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK);
+static void
+vee_store_finalize (CamelVeeStore *vee_store)
+{
+	g_hash_table_foreach (vee_store->unmatched_uids, cvs_free_unmatched, NULL);
+	g_hash_table_destroy (vee_store->unmatched_uids);
+	camel_object_unref (vee_store->folder_unmatched);
 }
 
 static void
-vee_construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
+vee_store_construct (CamelService *service,
+                     CamelSession *session,
+                     CamelProvider *provider,
+                     CamelURL *url,
+                     CamelException *ex)
 {
-	 CamelStore *store = (CamelStore *)service;
-	 CamelVeeStore *obj = (CamelVeeStore *)service;
+	CamelStore *store;
+	CamelVeeStore *vee_store;
 
-	 ((CamelServiceClass *) camel_vee_store_parent)->construct(service, session, provider, url, ex);
+	store = CAMEL_STORE (service);
+	vee_store = CAMEL_VEE_STORE (service);
+
+	 ((CamelServiceClass *) camel_vee_store_parent)->construct (service, session, provider, url, ex);
 
 	/* Set up unmatched folder */
 #ifndef VEE_UNMATCHED_ENABLE
-	obj->unmatched_uids = g_hash_table_new (g_str_hash, g_str_equal);
-	obj->folder_unmatched = (CamelVeeFolder *)camel_object_new (camel_vee_folder_get_type ());
-	camel_vee_folder_construct (obj->folder_unmatched, store, CAMEL_UNMATCHED_NAME, _("Unmatched"), CAMEL_STORE_FOLDER_PRIVATE);
+	vee_store->unmatched_uids = g_hash_table_new (g_str_hash, g_str_equal);
+	vee_store->folder_unmatched = (CamelVeeFolder *)camel_object_new (camel_vee_folder_get_type ());
+	camel_vee_folder_construct (vee_store->folder_unmatched, store, CAMEL_UNMATCHED_NAME, _("Unmatched"), CAMEL_STORE_FOLDER_PRIVATE);
 	camel_db_create_vfolder (store->cdb_r, _("Unmatched"), NULL);
 #endif
-
 }
 
 static gchar *
-vee_get_name (CamelService *service, gboolean brief)
+vee_store_get_name (CamelService *service,
+                    gboolean brief)
 {
 	return g_strdup ("Virtual Folder Store");
 }
 
-static void
-cvs_free_unmatched(gpointer key, gpointer value, gpointer data)
-{
-	g_free(key);
-}
-
-static void
-camel_vee_store_finalize (CamelObject *obj)
-{
-	CamelVeeStore *vstore = (CamelVeeStore *)obj;
-
-	g_hash_table_foreach(vstore->unmatched_uids, cvs_free_unmatched, NULL);
-	g_hash_table_destroy(vstore->unmatched_uids);
-	camel_object_unref(vstore->folder_unmatched);
-}
-
-/**
- * camel_vee_store_new:
- *
- * Create a new #CamelVeeStore object.
- *
- * Returns: new #CamelVeeStore object
- **/
-CamelVeeStore *
-camel_vee_store_new (void)
-{
-	CamelVeeStore *new = CAMEL_VEE_STORE(camel_object_new(camel_vee_store_get_type ()));
-	return new;
-}
-
-/* flags
-   1 = delete (0 = add)
-   2 = noselect
-*/
-#define CHANGE_ADD (0)
-#define CHANGE_DELETE (1)
-#define CHANGE_NOSELECT (2)
-
-static void
-change_folder(CamelStore *store, const gchar *name, guint32 flags, gint count)
-{
-	CamelFolderInfo *fi;
-	const gchar *tmp;
-	CamelURL *url;
-
-	fi = camel_folder_info_new ();
-	fi->full_name = g_strdup(name);
-	tmp = strrchr(name, '/');
-	if (tmp == NULL)
-		tmp = name;
-	else
-		tmp++;
-	fi->name = g_strdup(tmp);
-	url = camel_url_new("vfolder:", NULL);
-	camel_url_set_path(url, ((CamelService *)store)->url->path);
-	if (flags & CHANGE_NOSELECT)
-		camel_url_set_param(url, "noselect", "yes");
-	camel_url_set_fragment(url, name);
-	fi->uri = camel_url_to_string(url, 0);
-	camel_url_free(url);
-	/*fi->url = g_strdup_printf("vfolder:%s%s#%s", ((CamelService *)store)->url->path, (flags&CHANGE_NOSELECT)?";noselect=yes":"", name);*/
-	fi->unread = count;
-	fi->flags = CAMEL_FOLDER_VIRTUAL;
-	if (!(flags & CHANGE_DELETE))
-		fi->flags |= CAMEL_FOLDER_NOCHILDREN;
-	camel_object_trigger_event(store, (flags&CHANGE_DELETE)?"folder_deleted":"folder_created", fi);
-	camel_folder_info_free(fi);
-}
-
 static CamelFolder *
-vee_get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelException *ex)
+vee_store_get_folder (CamelStore *store,
+                      const gchar *folder_name,
+                      guint32 flags,
+                      CamelException *ex)
 {
 	CamelVeeFolder *vf;
 	CamelFolder *folder;
 	gchar *name, *p;
 
-	vf = (CamelVeeFolder *)camel_vee_folder_new(store, folder_name, flags);
+	vf = (CamelVeeFolder *)camel_vee_folder_new (store, folder_name, flags);
 	if (vf && ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0)) {
 		/* Check that parents exist, if not, create dummy ones */
-		name = alloca(strlen(((CamelFolder *)vf)->full_name)+1);
-		strcpy(name, ((CamelFolder *)vf)->full_name);
+		name = alloca (strlen (((CamelFolder *)vf)->full_name)+1);
+		strcpy (name, ((CamelFolder *)vf)->full_name);
 		p = name;
-		while ( (p = strchr(p, '/'))) {
+		while ( (p = strchr (p, '/'))) {
 			*p = 0;
 
-			folder = camel_object_bag_reserve(store->folders, name);
+			folder = camel_object_bag_reserve (store->folders, name);
 			if (folder == NULL) {
 				/* create a dummy vFolder for this, makes get_folder_info simpler */
-				folder = camel_vee_folder_new(store, name, flags);
-				camel_object_bag_add(store->folders, name, folder);
-				change_folder(store, name, CHANGE_ADD|CHANGE_NOSELECT, 0);
+				folder = camel_vee_folder_new (store, name, flags);
+				camel_object_bag_add (store->folders, name, folder);
+				change_folder (store, name, CHANGE_ADD|CHANGE_NOSELECT, 0);
 				/* FIXME: this sort of leaks folder, nobody owns a ref to it but us */
 			} else {
-				camel_object_unref(folder);
+				camel_object_unref (folder);
 			}
 			*p++='/';
 		}
 
-		change_folder(store, ((CamelFolder *)vf)->full_name, CHANGE_ADD, camel_folder_get_message_count((CamelFolder *)vf));
+		change_folder (store, ((CamelFolder *)vf)->full_name, CHANGE_ADD, camel_folder_get_message_count ((CamelFolder *)vf));
 	}
 
 	return (CamelFolder *)vf;
 }
 
-static CamelFolder *
-vee_get_trash (CamelStore *store, CamelException *ex)
+static void
+vee_store_rename_folder (CamelStore *store,
+                         const gchar *old,
+                         const gchar *new,
+                         CamelException *ex)
 {
-	return NULL;
-}
+	CamelFolder *folder, *oldfolder;
+	gchar *p, *name;
 
-static CamelFolder *
-vee_get_junk (CamelStore *store, CamelException *ex)
-{
-	return NULL;
+	d (printf ("vee rename folder '%s' '%s'\n", old, new));
+
+	if (strcmp (old, CAMEL_UNMATCHED_NAME) == 0) {
+		camel_exception_setv (
+			ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+			_("Cannot rename folder: %s: Invalid operation"), old);
+		return;
+	}
+
+	/* See if it exists, for vfolders, all folders are in the folders hash */
+	oldfolder = camel_object_bag_get (store->folders, old);
+	if (oldfolder == NULL) {
+		camel_exception_setv (
+			ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+			_("Cannot rename folder: %s: No such folder"), old);
+		return;
+	}
+
+	/* Check that new parents exist, if not, create dummy ones */
+	name = alloca (strlen (new)+1);
+	strcpy (name, new);
+	p = name;
+	while ( (p = strchr (p, '/'))) {
+		*p = 0;
+
+		folder = camel_object_bag_reserve (store->folders, name);
+		if (folder == NULL) {
+			/* create a dummy vFolder for this, makes get_folder_info simpler */
+			folder = camel_vee_folder_new (store, name, ((CamelVeeFolder *)oldfolder)->flags);
+			camel_object_bag_add (store->folders, name, folder);
+			change_folder (store, name, CHANGE_ADD|CHANGE_NOSELECT, 0);
+			/* FIXME: this sort of leaks folder, nobody owns a ref to it but us */
+		} else {
+			camel_object_unref (folder);
+		}
+		*p++='/';
+	}
+
+	camel_object_unref (oldfolder);
 }
 
-static gint
-vee_folder_cmp(gconstpointer ap, gconstpointer bp)
+static void
+vee_store_delete_folder (CamelStore *store,
+                         const gchar *folder_name,
+                         CamelException *ex)
 {
-	return strcmp(((CamelFolder **)ap)[0]->full_name, ((CamelFolder **)bp)[0]->full_name);
+	CamelFolder *folder;
+
+	if (strcmp (folder_name, CAMEL_UNMATCHED_NAME) == 0) {
+		camel_exception_setv (
+			ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+			_("Cannot delete folder: %s: Invalid operation"),
+			folder_name);
+		return;
+	}
+
+	folder = camel_object_bag_get (store->folders, folder_name);
+	if (folder) {
+		gchar *statefile;
+
+		camel_object_get (folder, NULL, CAMEL_OBJECT_STATE_FILE, &statefile, NULL);
+		if (statefile) {
+			g_unlink (statefile);
+			camel_object_free (folder, CAMEL_OBJECT_STATE_FILE, statefile);
+			camel_object_set (folder, NULL, CAMEL_OBJECT_STATE_FILE, NULL, NULL);
+		}
+
+		if ((((CamelVeeFolder *)folder)->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) {
+			/* what about now-empty parents?  ignore? */
+			change_folder (store, folder_name, CHANGE_DELETE, -1);
+		}
+
+		camel_object_unref (folder);
+	} else {
+		camel_exception_setv (
+			ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+			_("Cannot delete folder: %s: No such folder"),
+			folder_name);
+	}
 }
 
 static CamelFolderInfo *
-vee_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
+vee_store_get_folder_info (CamelStore *store,
+                           const gchar *top,
+                           guint32 flags,
+                           CamelException *ex)
 {
 	CamelFolderInfo *info, *res = NULL, *tail;
 	GPtrArray *folders;
@@ -258,57 +272,57 @@ vee_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelExc
 	CamelURL *url;
 	gint i;
 
-	d(printf("Get folder info '%s'\n", top?top:"<null>"));
+	d (printf ("Get folder info '%s'\n", top?top:"<null>"));
 
-	infos_hash = g_hash_table_new(g_str_hash, g_str_equal);
-	folders = camel_object_bag_list(store->folders);
-	qsort(folders->pdata, folders->len, sizeof(folders->pdata[0]), vee_folder_cmp);
+	infos_hash = g_hash_table_new (g_str_hash, g_str_equal);
+	folders = camel_object_bag_list (store->folders);
+	qsort (folders->pdata, folders->len, sizeof (folders->pdata[0]), vee_folder_cmp);
 	for (i=0;i<folders->len;i++) {
 		CamelVeeFolder *folder = folders->pdata[i];
 		gint add = FALSE;
 		gchar *name = ((CamelFolder *)folder)->full_name, *pname, *tmp;
 		CamelFolderInfo *pinfo;
 
-		d(printf("folder '%s'\n", name));
+		d (printf ("folder '%s'\n", name));
 
 		/* check we have to include this one */
 		if (top) {
-			gint namelen = strlen(name);
-			gint toplen = strlen(top);
+			gint namelen = strlen (name);
+			gint toplen = strlen (top);
 
 			add = ((namelen == toplen
-				&& strcmp(name, top) == 0)
+				&& strcmp (name, top) == 0)
 			       || ((namelen > toplen)
-				   && strncmp(name, top, toplen) == 0
+				   && strncmp (name, top, toplen) == 0
 				   && name[toplen] == '/'
 				   && ((flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)
-				       || strchr(name+toplen+1, '/') == NULL)));
+				       || strchr (name+toplen+1, '/') == NULL)));
 		} else {
 			add = (flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE)
-				|| strchr(name, '/') == NULL;
+				|| strchr (name, '/') == NULL;
 		}
 
-		d(printf("%sadding '%s'\n", add?"":"not ", name));
+		d (printf ("%sadding '%s'\n", add?"":"not ", name));
 
 		if (add) {
 			/* ensures unread is correct */
 			if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0)
-				camel_folder_refresh_info((CamelFolder *)folder, NULL);
-
-			info = camel_folder_info_new();
-			url = camel_url_new("vfolder:", NULL);
-			camel_url_set_path(url, ((CamelService *)((CamelFolder *)folder)->parent_store)->url->path);
-			camel_url_set_fragment(url, ((CamelFolder *)folder)->full_name);
-			info->uri = camel_url_to_string(url, 0);
-			camel_url_free(url);
+				camel_folder_refresh_info ((CamelFolder *)folder, NULL);
+
+			info = camel_folder_info_new ();
+			url = camel_url_new ("vfolder:", NULL);
+			camel_url_set_path (url, ((CamelService *)((CamelFolder *)folder)->parent_store)->url->path);
+			camel_url_set_fragment (url, ((CamelFolder *)folder)->full_name);
+			info->uri = camel_url_to_string (url, 0);
+			camel_url_free (url);
 /*
-			info->url = g_strdup_printf("vfolder:%s#%s", ((CamelService *)((CamelFolder *)folder)->parent_store)->url->path,
+			info->url = g_strdup_printf ("vfolder:%s#%s", ((CamelService *)((CamelFolder *)folder)->parent_store)->url->path,
 			((CamelFolder *)folder)->full_name);*/
-			info->full_name = g_strdup(((CamelFolder *)folder)->full_name);
-			info->name = g_strdup(((CamelFolder *)folder)->name);
-			info->unread = camel_folder_get_unread_message_count((CamelFolder *)folder);
+			info->full_name = g_strdup (((CamelFolder *)folder)->full_name);
+			info->name = g_strdup (((CamelFolder *)folder)->name);
+			info->unread = camel_folder_get_unread_message_count ((CamelFolder *)folder);
 			info->flags = CAMEL_FOLDER_NOCHILDREN|CAMEL_FOLDER_VIRTUAL;
-			g_hash_table_insert(infos_hash, info->full_name, info);
+			g_hash_table_insert (infos_hash, info->full_name, info);
 
 			if (res == NULL)
 				res = info;
@@ -317,18 +331,18 @@ vee_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelExc
 		}
 
 		/* check for parent, if present, update flags and if adding, update parent linkage */
-		pname = g_strdup(((CamelFolder *)folder)->full_name);
-		d(printf("looking up parent of '%s'\n", pname));
-		tmp = strrchr(pname, '/');
+		pname = g_strdup (((CamelFolder *)folder)->full_name);
+		d (printf ("looking up parent of '%s'\n", pname));
+		tmp = strrchr (pname, '/');
 		if (tmp) {
 			*tmp = 0;
-			pinfo = g_hash_table_lookup(infos_hash, pname);
+			pinfo = g_hash_table_lookup (infos_hash, pname);
 		} else
 			pinfo = NULL;
 
 		if (pinfo) {
 			pinfo->flags = (pinfo->flags & ~(CAMEL_FOLDER_CHILDREN|CAMEL_FOLDER_NOCHILDREN))|CAMEL_FOLDER_CHILDREN;
-			d(printf("updating parent flags for children '%s' %08x\n", pinfo->full_name, pinfo->flags));
+			d (printf ("updating parent flags for children '%s' %08x\n", pinfo->full_name, pinfo->flags));
 			tail = pinfo->child;
 			if (tail == NULL)
 				pinfo->child = info;
@@ -345,24 +359,24 @@ vee_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelExc
 			info->parent = pinfo;
 		}
 
-		g_free(pname);
-		camel_object_unref(folder);
+		g_free (pname);
+		camel_object_unref (folder);
 	}
-	g_ptr_array_free(folders, TRUE);
-	g_hash_table_destroy(infos_hash);
+	g_ptr_array_free (folders, TRUE);
+	g_hash_table_destroy (infos_hash);
 
 	/* and always add UNMATCHED, if scanning from top/etc */
 	/* FIXME[disk-summary] comment it out well */
-	if ((top == NULL || top[0] == 0 || strncmp(top, CAMEL_UNMATCHED_NAME, strlen(CAMEL_UNMATCHED_NAME)) == 0)) {
+	if ((top == NULL || top[0] == 0 || strncmp (top, CAMEL_UNMATCHED_NAME, strlen (CAMEL_UNMATCHED_NAME)) == 0)) {
 		info = camel_folder_info_new ();
-		url = camel_url_new("vfolder:", NULL);
-		camel_url_set_path(url, ((CamelService *)store)->url->path);
-		camel_url_set_fragment(url, CAMEL_UNMATCHED_NAME);
-		info->uri = camel_url_to_string(url, 0);
-		camel_url_free(url);
-		/*info->url = g_strdup_printf("vfolder:%s#%s", ((CamelService *)store)->url->path, CAMEL_UNMATCHED_NAME);*/
-		info->full_name = g_strdup(CAMEL_UNMATCHED_NAME);
-		info->name = g_strdup(_("Unmatched"));
+		url = camel_url_new ("vfolder:", NULL);
+		camel_url_set_path (url, ((CamelService *)store)->url->path);
+		camel_url_set_fragment (url, CAMEL_UNMATCHED_NAME);
+		info->uri = camel_url_to_string (url, 0);
+		camel_url_free (url);
+		/*info->url = g_strdup_printf ("vfolder:%s#%s", ((CamelService *)store)->url->path, CAMEL_UNMATCHED_NAME);*/
+		info->full_name = g_strdup (CAMEL_UNMATCHED_NAME);
+		info->name = g_strdup (_("Unmatched"));
 		info->unread = -1;
 		info->flags = CAMEL_FOLDER_NOCHILDREN|CAMEL_FOLDER_NOINFERIORS|CAMEL_FOLDER_SYSTEM|CAMEL_FOLDER_VIRTUAL;
 
@@ -379,81 +393,78 @@ vee_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelExc
 	return res;
 }
 
-static void
-vee_delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
+static CamelFolder *
+vee_store_get_trash (CamelStore *store,
+                     CamelException *ex)
 {
-	CamelFolder *folder;
+	return NULL;
+}
 
-	if (strcmp(folder_name, CAMEL_UNMATCHED_NAME) == 0) {
-		camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
-				     _("Cannot delete folder: %s: Invalid operation"), folder_name);
-		return;
-	}
+static CamelFolder *
+vee_store_get_junk (CamelStore *store,
+                    CamelException *ex)
+{
+	return NULL;
+}
 
-	folder = camel_object_bag_get(store->folders, folder_name);
-	if (folder) {
-		gchar *statefile;
+static void
+camel_vee_store_class_init (CamelVeeStoreClass *class)
+{
+	CamelServiceClass *service_class;
+	CamelStoreClass *store_class;
 
-		camel_object_get(folder, NULL, CAMEL_OBJECT_STATE_FILE, &statefile, NULL);
-		if (statefile) {
-			g_unlink(statefile);
-			camel_object_free(folder, CAMEL_OBJECT_STATE_FILE, statefile);
-			camel_object_set(folder, NULL, CAMEL_OBJECT_STATE_FILE, NULL, NULL);
-		}
+	camel_vee_store_parent = (CamelStoreClass *)camel_store_get_type ();
 
-		if ((((CamelVeeFolder *)folder)->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) {
-			/* what about now-empty parents?  ignore? */
-			change_folder(store, folder_name, CHANGE_DELETE, -1);
-		}
+	service_class = CAMEL_SERVICE_CLASS (class);
+	service_class->construct = vee_store_construct;
+	service_class->get_name = vee_store_get_name;
 
-		camel_object_unref(folder);
-	} else {
-		camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
-				     _("Cannot delete folder: %s: No such folder"), folder_name);
-	}
+	store_class = CAMEL_STORE_CLASS (class);
+	store_class->get_folder = vee_store_get_folder;
+	store_class->rename_folder = vee_store_rename_folder;
+	store_class->delete_folder = vee_store_delete_folder;
+	store_class->get_folder_info = vee_store_get_folder_info;
+	store_class->free_folder_info = camel_store_free_folder_info_full;
+	store_class->get_trash = vee_store_get_trash;
+	store_class->get_junk = vee_store_get_junk;
 }
 
 static void
-vee_rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelException *ex)
+camel_vee_store_init (CamelVeeStore *vee_store)
 {
-	CamelFolder *folder, *oldfolder;
-	gchar *p, *name;
+	CamelStore *store = CAMEL_STORE (vee_store);
 
-	d(printf("vee rename folder '%s' '%s'\n", old, new));
+	/* we dont want a vtrash/vjunk on this one */
+	store->flags &= ~(CAMEL_STORE_VTRASH | CAMEL_STORE_VJUNK);
+}
 
-	if (strcmp(old, CAMEL_UNMATCHED_NAME) == 0) {
-		camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
-				     _("Cannot rename folder: %s: Invalid operation"), old);
-		return;
-	}
+CamelType
+camel_vee_store_get_type (void)
+{
+	static CamelType type = CAMEL_INVALID_TYPE;
 
-	/* See if it exists, for vfolders, all folders are in the folders hash */
-	oldfolder = camel_object_bag_get(store->folders, old);
-	if (oldfolder == NULL) {
-		camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
-				     _("Cannot rename folder: %s: No such folder"), old);
-		return;
+	if (type == CAMEL_INVALID_TYPE) {
+		type = camel_type_register (camel_store_get_type (), "CamelVeeStore",
+					    sizeof (CamelVeeStore),
+					    sizeof (CamelVeeStoreClass),
+					    (CamelObjectClassInitFunc) camel_vee_store_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_vee_store_init,
+					    (CamelObjectFinalizeFunc) vee_store_finalize);
 	}
 
-	/* Check that new parents exist, if not, create dummy ones */
-	name = alloca(strlen(new)+1);
-	strcpy(name, new);
-	p = name;
-	while ( (p = strchr(p, '/'))) {
-		*p = 0;
-
-		folder = camel_object_bag_reserve(store->folders, name);
-		if (folder == NULL) {
-			/* create a dummy vFolder for this, makes get_folder_info simpler */
-			folder = camel_vee_folder_new(store, name, ((CamelVeeFolder *)oldfolder)->flags);
-			camel_object_bag_add(store->folders, name, folder);
-			change_folder(store, name, CHANGE_ADD|CHANGE_NOSELECT, 0);
-			/* FIXME: this sort of leaks folder, nobody owns a ref to it but us */
-		} else {
-			camel_object_unref(folder);
-		}
-		*p++='/';
-	}
+	return type;
+}
 
-	camel_object_unref(oldfolder);
+/**
+ * camel_vee_store_new:
+ *
+ * Create a new #CamelVeeStore object.
+ *
+ * Returns: new #CamelVeeStore object
+ **/
+CamelVeeStore *
+camel_vee_store_new (void)
+{
+	return CAMEL_VEE_STORE (camel_object_new (camel_vee_store_get_type ()));
 }
diff --git a/camel/camel-vee-summary.c b/camel/camel-vee-summary.c
index 13eecde..a447162 100644
--- a/camel/camel-vee-summary.c
+++ b/camel/camel-vee-summary.c
@@ -61,8 +61,7 @@ vee_message_info_clone(CamelFolderSummary *s, const CamelMessageInfo *mi)
 
 	to = (CamelVeeMessageInfo *)camel_message_info_new(s);
 
-	to->summary = from->summary;
-	camel_object_ref (to->summary);
+	to->summary = camel_object_ref (from->summary);
 	to->info.summary = s;
 	to->info.uid = camel_pstring_strdup(from->info.uid);
 
@@ -367,37 +366,29 @@ message_info_from_uid (CamelFolderSummary *s, const gchar *uid)
 }
 
 static void
-camel_vee_summary_class_init (CamelVeeSummaryClass *klass)
+camel_vee_summary_class_init (CamelVeeSummaryClass *class)
 {
-	((CamelFolderSummaryClass *)klass)->message_info_clone = vee_message_info_clone;
-	((CamelFolderSummaryClass *)klass)->message_info_free = vee_message_info_free;
-
-	((CamelFolderSummaryClass *)klass)->info_ptr = vee_info_ptr;
-	((CamelFolderSummaryClass *)klass)->info_uint32 = vee_info_uint32;
-	((CamelFolderSummaryClass *)klass)->info_time = vee_info_time;
-	((CamelFolderSummaryClass *)klass)->info_user_flag = vee_info_user_flag;
-	((CamelFolderSummaryClass *)klass)->info_user_tag = vee_info_user_tag;
-
-#if 0
-	((CamelFolderSummaryClass *)klass)->info_set_string = vee_info_set_string;
-	((CamelFolderSummaryClass *)klass)->info_set_uint32 = vee_info_set_uint32;
-	((CamelFolderSummaryClass *)klass)->info_set_time = vee_info_set_time;
-	((CamelFolderSummaryClass *)klass)->info_set_references = vee_info_set_references;
-#endif
-	((CamelFolderSummaryClass *)klass)->info_set_user_flag = vee_info_set_user_flag;
-	((CamelFolderSummaryClass *)klass)->info_set_user_tag = vee_info_set_user_tag;
-
-	((CamelFolderSummaryClass *)klass)->info_set_flags = vee_info_set_flags;
-	((CamelFolderSummaryClass *)klass)->message_info_from_uid = message_info_from_uid;
+	CamelFolderSummaryClass *folder_summary_class;
+
+	folder_summary_class = CAMEL_FOLDER_SUMMARY_CLASS (class);
+	folder_summary_class->message_info_size = sizeof (CamelVeeMessageInfo);
+	folder_summary_class->content_info_size = 0;
+	folder_summary_class->message_info_clone = vee_message_info_clone;
+	folder_summary_class->message_info_free = vee_message_info_free;
+	folder_summary_class->info_ptr = vee_info_ptr;
+	folder_summary_class->info_uint32 = vee_info_uint32;
+	folder_summary_class->info_time = vee_info_time;
+	folder_summary_class->info_user_flag = vee_info_user_flag;
+	folder_summary_class->info_user_tag = vee_info_user_tag;
+	folder_summary_class->info_set_user_flag = vee_info_set_user_flag;
+	folder_summary_class->info_set_user_tag = vee_info_set_user_tag;
+	folder_summary_class->info_set_flags = vee_info_set_flags;
+	folder_summary_class->message_info_from_uid = message_info_from_uid;
 }
 
 static void
-camel_vee_summary_init (CamelVeeSummary *obj)
+camel_vee_summary_init (CamelVeeSummary *vee_summary)
 {
-	CamelFolderSummary *s = (CamelFolderSummary *)obj;
-
-	s->message_info_size = sizeof(CamelVeeMessageInfo);
-	s->content_info_size = 0;
 }
 
 CamelType
@@ -488,10 +479,8 @@ camel_vee_summary_add(CamelVeeSummary *s, CamelFolderSummary *summary, const gch
 		/* Possible that the entry is loaded, see if it has the summary */
 		d(g_message ("%s - already there\n", vuid));
 		g_free (vuid);
-		if (!mi->summary) {
-			mi->summary = summary;
-			camel_object_ref(summary);
-		}
+		if (!mi->summary)
+			mi->summary = camel_object_ref (summary);
 
 		camel_message_info_ref (mi);
 		return mi;
diff --git a/camel/camel-vee-summary.h b/camel/camel-vee-summary.h
index 7a166d9..0b7855b 100644
--- a/camel/camel-vee-summary.h
+++ b/camel/camel-vee-summary.h
@@ -28,7 +28,6 @@
 #define CAMEL_VEE_SUMMARY_H
 
 #include <camel/camel-folder-summary.h>
-#include <camel/camel-exception.h>
 
 #define CAMEL_VEE_SUMMARY(obj)         CAMEL_CHECK_CAST (obj, camel_vee_summary_get_type (), CamelVeeSummary)
 #define CAMEL_VEE_SUMMARY_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_vee_summary_get_type (), CamelVeeSummaryClass)
diff --git a/camel/camel-vtrash-folder.c b/camel/camel-vtrash-folder.c
index 6e43edc..a368547 100644
--- a/camel/camel-vtrash-folder.c
+++ b/camel/camel-vtrash-folder.c
@@ -27,7 +27,6 @@
 
 #include <string.h>
 
-#include <glib.h>
 #include <glib/gi18n-lib.h>
 
 #include "camel-db.h"
@@ -39,9 +38,6 @@
 #include "camel-vtrash-folder.h"
 #include "camel-string-utils.h"
 
-/* Returns the class for a CamelFolder */
-#define CF_CLASS(so) ((CamelFolderClass *)((CamelObject *)(so))->klass)
-
 static struct {
 	const gchar *full_name;
 	const gchar *name;
@@ -57,67 +53,38 @@ static struct {
 	  N_("Cannot copy messages to the Junk folder"), "junk" },
 };
 
-static CamelVeeFolderClass *camel_vtrash_folder_parent;
+struct _transfer_data {
+	CamelFolder *folder;
+	CamelFolder *dest;
+	GPtrArray *uids;
+	gboolean delete;
+};
 
-static void camel_vtrash_folder_class_init (CamelVTrashFolderClass *klass);
+static CamelVeeFolderClass *camel_vtrash_folder_parent;
 
 static void
-camel_vtrash_folder_init (CamelVTrashFolder *vtrash)
-{
-	/*CamelFolder *folder = CAMEL_FOLDER (vtrash);*/
-}
-
-CamelType
-camel_vtrash_folder_get_type (void)
-{
-	static CamelType type = CAMEL_INVALID_TYPE;
-
-	if (type == CAMEL_INVALID_TYPE) {
-		type = camel_type_register (camel_vee_folder_get_type (),
-					    "CamelVTrashFolder",
-					    sizeof (CamelVTrashFolder),
-					    sizeof (CamelVTrashFolderClass),
-					    (CamelObjectClassInitFunc) camel_vtrash_folder_class_init,
-					    NULL,
-					    (CamelObjectInitFunc) camel_vtrash_folder_init,
-					    NULL);
-	}
-
-	return type;
-}
-
-/**
- * camel_vtrash_folder_new:
- * @parent_store: the parent #CamelVeeStore object
- * @type: type of vfolder, #CAMEL_VTRASH_FOLDER_TRASH or
- * #CAMEL_VTRASH_FOLDER_JUNK currently.
- *
- * Create a new CamelVTrashFolder object.
- *
- * Returns: a new #CamelVTrashFolder object
- **/
-CamelFolder *
-camel_vtrash_folder_new (CamelStore *parent_store, camel_vtrash_folder_t type)
+transfer_messages (CamelFolder *folder,
+                   struct _transfer_data *md,
+                   CamelException *ex)
 {
-	CamelVTrashFolder *vtrash;
-
-	g_assert(type < CAMEL_VTRASH_FOLDER_LAST);
-
-	vtrash = (CamelVTrashFolder *)camel_object_new(camel_vtrash_folder_get_type());
-	camel_vee_folder_construct(CAMEL_VEE_FOLDER (vtrash), parent_store, vdata[type].full_name, _(vdata[type].name),
-				   CAMEL_STORE_FOLDER_PRIVATE|CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_VEE_FOLDER_AUTO|CAMEL_STORE_VEE_FOLDER_SPECIAL);
+	gint i;
 
-	((CamelFolder *)vtrash)->folder_flags |= vdata[type].flags;
-	camel_vee_folder_set_expression((CamelVeeFolder *)vtrash, vdata[type].expr);
-	vtrash->bit = vdata[type].bit;
-	vtrash->type = type;
+	if (!camel_exception_is_set (ex))
+		camel_folder_transfer_messages_to (
+			md->folder, md->uids, md->dest, NULL, md->delete, ex);
 
-	return (CamelFolder *)vtrash;
+	for (i=0;i<md->uids->len;i++)
+		g_free(md->uids->pdata[i]);
+	g_ptr_array_free(md->uids, TRUE);
+	camel_object_unref (md->folder);
+	g_free(md);
 }
 
 /* This entire code will be useless, since we sync the counts always. */
 static gint
-vtrash_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
+vtrash_folder_getv (CamelObject *object,
+                    CamelException *ex,
+                    CamelArgGetV *args)
 {
 	CamelFolder *folder = (CamelFolder *)object;
 	gint i;
@@ -200,44 +167,28 @@ vtrash_getv(CamelObject *object, CamelException *ex, CamelArgGetV *args)
 		arg->tag = (tag & CAMEL_ARG_TYPE) | CAMEL_ARG_IGNORE;
 	}
 
-	return ((CamelObjectClass *)camel_vtrash_folder_parent)->getv(object, ex, args);
-}
-
-static void
-vtrash_append_message (CamelFolder *folder, CamelMimeMessage *message,
-		       const CamelMessageInfo *info, gchar **appended_uid,
-		       CamelException *ex)
-{
-	camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s",
-			     _(vdata[((CamelVTrashFolder *)folder)->type].error_copy));
+	return CAMEL_OBJECT_CLASS (camel_vtrash_folder_parent)->getv (object, ex, args);
 }
 
-struct _transfer_data {
-	CamelFolder *folder;
-	CamelFolder *dest;
-	GPtrArray *uids;
-	gboolean delete;
-};
-
 static void
-transfer_messages(CamelFolder *folder, struct _transfer_data *md, CamelException *ex)
+vtrash_folder_append_message (CamelFolder *folder,
+                              CamelMimeMessage *message,
+                              const CamelMessageInfo *info,
+                              gchar **appended_uid,
+		              CamelException *ex)
 {
-	gint i;
-
-	if (!camel_exception_is_set (ex))
-		camel_folder_transfer_messages_to(md->folder, md->uids, md->dest, NULL, md->delete, ex);
-
-	for (i=0;i<md->uids->len;i++)
-		g_free(md->uids->pdata[i]);
-	g_ptr_array_free(md->uids, TRUE);
-	camel_object_unref((CamelObject *)md->folder);
-	g_free(md);
+	camel_exception_setv (
+		ex, CAMEL_EXCEPTION_SYSTEM, "%s",
+		_(vdata[((CamelVTrashFolder *)folder)->type].error_copy));
 }
 
 static void
-vtrash_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
-			     CamelFolder *dest, GPtrArray **transferred_uids,
-			     gboolean delete_originals, CamelException *ex)
+vtrash_folder_transfer_messages_to (CamelFolder *source,
+                                    GPtrArray *uids,
+                                    CamelFolder *dest,
+                                    GPtrArray **transferred_uids,
+                                    gboolean delete_originals,
+                                    CamelException *ex)
 {
 	CamelVeeMessageInfo *mi;
 	gint i;
@@ -257,8 +208,9 @@ vtrash_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
 	if (CAMEL_IS_VTRASH_FOLDER (dest)) {
 		/* Copy to trash is meaningless. */
 		if (!delete_originals) {
-			camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, "%s",
-					     _(vdata[((CamelVTrashFolder *)dest)->type].error_copy));
+			camel_exception_setv (
+				ex, CAMEL_EXCEPTION_SYSTEM, "%s",
+				_(vdata[((CamelVTrashFolder *)dest)->type].error_copy));
 			return;
 		}
 
@@ -290,8 +242,7 @@ vtrash_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
 			md = g_hash_table_lookup(batch, mi->summary->folder);
 			if (md == NULL) {
 				md = g_malloc0(sizeof(*md));
-				md->folder = mi->summary->folder;
-				camel_object_ref((CamelObject *)md->folder);
+				md->folder = camel_object_ref (mi->summary->folder);
 				md->uids = g_ptr_array_new();
 				md->dest = dest;
 				g_hash_table_insert(batch, mi->summary->folder, md);
@@ -312,15 +263,71 @@ vtrash_transfer_messages_to (CamelFolder *source, GPtrArray *uids,
 }
 
 static void
-camel_vtrash_folder_class_init (CamelVTrashFolderClass *klass)
+camel_vtrash_folder_class_init (CamelVTrashFolderClass *class)
 {
-	CamelFolderClass *folder_class = (CamelFolderClass *) klass;
+	CamelObjectClass *camel_object_class;
+	CamelFolderClass *folder_class;
 
 	camel_vtrash_folder_parent = CAMEL_VEE_FOLDER_CLASS(camel_vee_folder_get_type());
 
 	/* Not required from here on. We don't count */
-	((CamelObjectClass *)klass)->getv = vtrash_getv;
+	camel_object_class = CAMEL_OBJECT_CLASS (class);
+	camel_object_class->getv = vtrash_folder_getv;
+
+	folder_class = CAMEL_FOLDER_CLASS (class);
+	folder_class->append_message = vtrash_folder_append_message;
+	folder_class->transfer_messages_to = vtrash_folder_transfer_messages_to;
+}
+
+static void
+camel_vtrash_folder_init (CamelVTrashFolder *vtrash_folder)
+{
+}
+
+CamelType
+camel_vtrash_folder_get_type (void)
+{
+	static CamelType type = CAMEL_INVALID_TYPE;
+
+	if (type == CAMEL_INVALID_TYPE) {
+		type = camel_type_register (camel_vee_folder_get_type (),
+					    "CamelVTrashFolder",
+					    sizeof (CamelVTrashFolder),
+					    sizeof (CamelVTrashFolderClass),
+					    (CamelObjectClassInitFunc) camel_vtrash_folder_class_init,
+					    NULL,
+					    (CamelObjectInitFunc) camel_vtrash_folder_init,
+					    NULL);
+	}
 
-	folder_class->append_message = vtrash_append_message;
-	folder_class->transfer_messages_to = vtrash_transfer_messages_to;
+	return type;
+}
+
+/**
+ * camel_vtrash_folder_new:
+ * @parent_store: the parent #CamelVeeStore object
+ * @type: type of vfolder, #CAMEL_VTRASH_FOLDER_TRASH or
+ * #CAMEL_VTRASH_FOLDER_JUNK currently.
+ *
+ * Create a new CamelVTrashFolder object.
+ *
+ * Returns: a new #CamelVTrashFolder object
+ **/
+CamelFolder *
+camel_vtrash_folder_new (CamelStore *parent_store, camel_vtrash_folder_t type)
+{
+	CamelVTrashFolder *vtrash;
+
+	g_assert(type < CAMEL_VTRASH_FOLDER_LAST);
+
+	vtrash = (CamelVTrashFolder *)camel_object_new(camel_vtrash_folder_get_type());
+	camel_vee_folder_construct(CAMEL_VEE_FOLDER (vtrash), parent_store, vdata[type].full_name, _(vdata[type].name),
+				   CAMEL_STORE_FOLDER_PRIVATE|CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_VEE_FOLDER_AUTO|CAMEL_STORE_VEE_FOLDER_SPECIAL);
+
+	((CamelFolder *)vtrash)->folder_flags |= vdata[type].flags;
+	camel_vee_folder_set_expression((CamelVeeFolder *)vtrash, vdata[type].expr);
+	vtrash->bit = vdata[type].bit;
+	vtrash->type = type;
+
+	return (CamelFolder *)vtrash;
 }
diff --git a/camel/providers/groupwise/camel-groupwise-folder.c b/camel/providers/groupwise/camel-groupwise-folder.c
index b2c0180..e4d8f2b 100644
--- a/camel/providers/groupwise/camel-groupwise-folder.c
+++ b/camel/providers/groupwise/camel-groupwise-folder.c
@@ -1448,8 +1448,7 @@ groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
 		msg->cnc = cnc;
 		msg->t_str = g_strdup (old_sync_time);
 		msg->container_id = g_strdup (container_id);
-		msg->folder = folder;
-		camel_object_ref (folder);
+		msg->folder = camel_object_ref (folder);
 		camel_folder_freeze (folder);
 		camel_session_thread_queue (session, &msg->msg, 0);
 		/*thread creation and queueing done*/
diff --git a/camel/providers/groupwise/camel-groupwise-store.c b/camel/providers/groupwise/camel-groupwise-store.c
index ec4fb42..c779856 100644
--- a/camel/providers/groupwise/camel-groupwise-store.c
+++ b/camel/providers/groupwise/camel-groupwise-store.c
@@ -260,10 +260,8 @@ groupwise_store_set_current_folder (CamelGroupwiseStore *groupwise_store, CamelF
 		groupwise_store->current_folder = NULL;
 	}
 
-	if (folder) {
-		camel_object_ref (folder);
-		groupwise_store->current_folder = folder;
-	}
+	if (folder)
+		groupwise_store->current_folder = camel_object_ref (folder);
 
 	CAMEL_SERVICE_REC_UNLOCK (groupwise_store, connect_lock);
 }
diff --git a/camel/providers/groupwise/camel-groupwise-summary.c b/camel/providers/groupwise/camel-groupwise-summary.c
index 09b1f3c..87d8aa2 100644
--- a/camel/providers/groupwise/camel-groupwise-summary.c
+++ b/camel/providers/groupwise/camel-groupwise-summary.c
@@ -109,6 +109,8 @@ camel_groupwise_summary_class_init (CamelGroupwiseSummaryClass *klass)
 
 	camel_groupwise_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS (camel_type_get_global_classfuncs (camel_folder_summary_get_type()));
 
+	cfs_class->message_info_size = sizeof(CamelGroupwiseMessageInfo);
+	cfs_class->content_info_size = sizeof(CamelGroupwiseMessageContentInfo);
 	cfs_class->message_info_clone = gw_message_info_clone;
 	cfs_class->summary_header_load = gw_summary_header_load;
 	cfs_class->summary_header_save = gw_summary_header_save;
@@ -132,10 +134,6 @@ camel_groupwise_summary_init (CamelGroupwiseSummary *obj)
 {
 	CamelFolderSummary *s = (CamelFolderSummary *)obj;
 
-	/* subclasses need to set the right instance data sizes */
-	s->message_info_size = sizeof(CamelGroupwiseMessageInfo);
-	s->content_info_size = sizeof(CamelGroupwiseMessageContentInfo);
-
 	/* Meta-summary - Overriding UID len */
 	s->meta_summary->uid_len = 2048;
 }
diff --git a/camel/providers/groupwise/camel-groupwise-utils.c b/camel/providers/groupwise/camel-groupwise-utils.c
index 4209bfd..1f125b4 100644
--- a/camel/providers/groupwise/camel-groupwise-utils.c
+++ b/camel/providers/groupwise/camel-groupwise-utils.c
@@ -439,8 +439,7 @@ camel_groupwise_util_item_from_message (EGwConnection *cnc, CamelMimeMessage *me
 				camel_object_unref (filter);
 			} else {
 				/* US-ASCII or UTF-8 */
-				filtered_stream = (CamelStream *) content;
-				camel_object_ref (content);
+				filtered_stream = camel_object_ref (content);
 			}
 
 			camel_data_wrapper_decode_to_stream (dw, filtered_stream);
@@ -669,8 +668,7 @@ do_multipart (EGwConnection *cnc, EGwItem *item, CamelMultipart *mp, GSList **at
 				camel_object_unref (filter);
 			} else {
 				/* US-ASCII or UTF-8 */
-				filtered_stream = (CamelStream *) content;
-				camel_object_ref (content);
+				filtered_stream = camel_object_ref (content);
 			}
 
 			camel_data_wrapper_decode_to_stream (dw, filtered_stream);
diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c
index 49175e7..bacf17f 100644
--- a/camel/providers/imap/camel-imap-command.c
+++ b/camel/providers/imap/camel-imap-command.c
@@ -95,9 +95,9 @@ camel_imap_command (CamelImapStore *store, CamelFolder *folder,
 		cmd = imap_command_strdup_vprintf (store, fmt, ap);
 		va_end (ap);
 	} else {
-		camel_object_ref(folder);
+		camel_object_ref (folder);
 		if (store->current_folder)
-			camel_object_unref(store->current_folder);
+			camel_object_unref (store->current_folder);
 		store->current_folder = folder;
 		cmd = imap_command_strdup_printf (store, "SELECT %F", folder->full_name);
 	}
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index ba1fa83..e7a9209 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -2670,7 +2670,7 @@ get_content (CamelImapFolder *imap_folder, const gchar *uid,
 			ret = camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (body_mp), stream);
 			camel_object_unref (CAMEL_OBJECT (stream));
 			if (ret == -1) {
-				camel_object_unref ((CamelObject *) body_mp);
+				camel_object_unref ( body_mp);
 				return NULL;
 			}
 		}
@@ -2746,10 +2746,10 @@ get_content (CamelImapFolder *imap_folder, const gchar *uid,
 			}
 
 			camel_medium_set_content (CAMEL_MEDIUM (part), content);
-			camel_object_unref(content);
+			camel_object_unref (content);
 
 			camel_multipart_add_part (body_mp, part);
-			camel_object_unref(part);
+			camel_object_unref (part);
 
 			ci = ci->next;
 		}
@@ -3094,7 +3094,7 @@ imap_sync_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
 	}
 	msg = imap_get_message(folder, uid, ex);
 	if (msg)
-		camel_object_unref(msg);
+		camel_object_unref (msg);
 }
 
 /* FIXME Remove it after confirming
diff --git a/camel/providers/imap/camel-imap-search.c b/camel/providers/imap/camel-imap-search.c
index 560a3bf..a9d53c6 100644
--- a/camel/providers/imap/camel-imap-search.c
+++ b/camel/providers/imap/camel-imap-search.c
@@ -125,7 +125,7 @@ camel_imap_search_finalize(CamelImapSearch *is)
 		free_match(is, mr);
 	g_hash_table_destroy(is->matches_hash);
 	if (is->cache)
-		camel_object_unref((CamelObject *)is->cache);
+		camel_object_unref (is->cache);
 }
 
 CamelType
@@ -237,7 +237,7 @@ save_match(CamelImapSearch *is, struct _match_record *mr)
 		ret = -1;
 	}
 
-	camel_object_unref((CamelObject *)stream);
+	camel_object_unref (stream);
 	return ret;
 }
 
@@ -295,7 +295,7 @@ load_match(CamelImapSearch *is, gchar hash[17], gint argc, struct _ESExpResult *
 			d(printf(" file format invalid/validity changed\n"));
 			memset(&header, 0, sizeof(header));
 		}
-		camel_object_unref((CamelObject *)stream);
+		camel_object_unref (stream);
 	} else {
 		d(printf(" no cache entry found\n"));
 	}
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 5737d67..81298b7 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -165,7 +165,7 @@ camel_imap_store_finalize (CamelObject *object)
 
 	if (imap_store->summary) {
 		camel_store_summary_save((CamelStoreSummary *)imap_store->summary);
-		camel_object_unref(imap_store->summary);
+		camel_object_unref (imap_store->summary);
 	}
 
 	if (imap_store->base_url)
@@ -1178,7 +1178,7 @@ imap_store_refresh_folders (CamelImapStore *store, CamelException *ex)
 
 		/* NB: we can have vtrash folders also in our store ... bit hacky */
 		if (!CAMEL_IS_IMAP_FOLDER(folder)) {
-			camel_object_unref(folder);
+			camel_object_unref (folder);
 			continue;
 		}
 
@@ -1194,12 +1194,12 @@ imap_store_refresh_folders (CamelImapStore *store, CamelException *ex)
 			 * after being offline */
 
 			namedup = g_strdup (folder->full_name);
-			camel_object_unref(folder);
+			camel_object_unref (folder);
 			imap_folder_effectively_unsubscribed (store, namedup, ex);
 			imap_forget_folder (store, namedup, ex);
 			g_free (namedup);
 		} else
-			camel_object_unref(folder);
+			camel_object_unref (folder);
 	}
 
 	g_ptr_array_free (folders, TRUE);
@@ -1573,13 +1573,13 @@ imap_disconnect (CamelService *service, gboolean clean, CamelException *ex)
 
 	if (store->istream) {
 		camel_stream_close(store->istream);
-		camel_object_unref(store->istream);
+		camel_object_unref (store->istream);
 		store->istream = NULL;
 	}
 
 	if (store->ostream) {
 		camel_stream_close(store->ostream);
-		camel_object_unref(store->ostream);
+		camel_object_unref (store->ostream);
 		store->ostream = NULL;
 	}
 
@@ -2011,8 +2011,7 @@ get_folder (CamelStore *store, const gchar *folder_name, guint32 flags, CamelExc
 	if (new_folder) {
 		CamelException local_ex;
 
-		imap_store->current_folder = new_folder;
-		camel_object_ref (new_folder);
+		imap_store->current_folder = camel_object_ref (new_folder);
 		camel_exception_init (&local_ex);
 		camel_imap_folder_selected (new_folder, response, &local_ex);
 
@@ -2699,7 +2698,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
 
 		if (!folder->summary)
 			camel_object_unref (ims);
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 	}
 }
 
@@ -2741,7 +2740,7 @@ refresh_free(CamelSession *session, CamelSessionThreadMsg *msg)
 {
 	struct _refresh_msg *m = (struct _refresh_msg *)msg;
 
-	camel_object_unref(m->store);
+	camel_object_unref (m->store);
 	camel_exception_clear(&m->ex);
 }
 
@@ -2787,8 +2786,7 @@ get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelExcept
 				imap_store->refresh_stamp = now;
 
 				m = camel_session_thread_msg_new(((CamelService *)store)->session, &refresh_ops, sizeof(*m));
-				m->store = store;
-				camel_object_ref(store);
+				m->store = camel_object_ref (store);
 				camel_exception_init(&m->ex);
 				camel_session_thread_queue(((CamelService *)store)->session, &m->msg, 0);
 			}
diff --git a/camel/providers/imap/camel-imap-summary.c b/camel/providers/imap/camel-imap-summary.c
index d5ef241..1769477 100644
--- a/camel/providers/imap/camel-imap-summary.c
+++ b/camel/providers/imap/camel-imap-summary.c
@@ -104,7 +104,8 @@ camel_imap_summary_class_init (CamelImapSummaryClass *klass)
 	camel_imap_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS (camel_type_get_global_classfuncs (camel_folder_summary_get_type()));
 
 	cfs_class->message_info_clone = imap_message_info_clone;
-
+	cfs_class->message_info_size = sizeof (CamelImapMessageInfo);
+	cfs_class->content_info_size = sizeof (CamelImapMessageContentInfo);
 	cfs_class->summary_header_load = summary_header_load;
 	cfs_class->summary_header_save = summary_header_save;
 	cfs_class->message_info_load = message_info_load;
@@ -125,11 +126,6 @@ camel_imap_summary_class_init (CamelImapSummaryClass *klass)
 static void
 camel_imap_summary_init (CamelImapSummary *obj)
 {
-	CamelFolderSummary *s = (CamelFolderSummary *)obj;
-
-	/* subclasses need to set the right instance data sizes */
-	s->message_info_size = sizeof(CamelImapMessageInfo);
-	s->content_info_size = sizeof(CamelImapMessageContentInfo);
 }
 
 static gint
diff --git a/camel/providers/imap/camel-imap-wrapper.c b/camel/providers/imap/camel-imap-wrapper.c
index cf0bd9b..2bb5679 100644
--- a/camel/providers/imap/camel-imap-wrapper.c
+++ b/camel/providers/imap/camel-imap-wrapper.c
@@ -108,8 +108,7 @@ imap_wrapper_hydrate (CamelImapWrapper *imap_wrapper, CamelStream *stream)
 {
 	CamelDataWrapper *data_wrapper = (CamelDataWrapper *) imap_wrapper;
 
-	camel_object_ref (stream);
-	data_wrapper->stream = stream;
+	data_wrapper->stream = camel_object_ref (stream);
 	data_wrapper->offline = FALSE;
 
 	camel_object_unref (imap_wrapper->folder);
@@ -174,8 +173,7 @@ camel_imap_wrapper_new (CamelImapFolder *imap_folder,
 	((CamelDataWrapper *)imap_wrapper)->offline = !sync_offline;
 	((CamelDataWrapper *)imap_wrapper)->encoding = encoding;
 
-	imap_wrapper->folder = imap_folder;
-	camel_object_ref (imap_folder);
+	imap_wrapper->folder = camel_object_ref (imap_folder);
 	imap_wrapper->uid = g_strdup (uid);
 	imap_wrapper->part_spec = g_strdup (part_spec);
 
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index a6ed6a1..2f6d36f 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -200,11 +200,11 @@ imapx_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
 	
 		g_mutex_lock (ifolder->stream_lock);
 		if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg, stream) == -1) {
-			camel_object_unref(msg);
+			camel_object_unref (msg);
 			msg = NULL;
 		}
 		g_mutex_unlock (ifolder->stream_lock);
-		camel_object_unref(stream);
+		camel_object_unref (stream);
 	}
 
 	return msg;
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 25ef124..3832bbd 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -423,9 +423,9 @@ imapx_command_add_part(CamelIMAPXCommand *ic, camel_imapx_command_part_t type, g
 			camel_stream_reset((CamelStream *)ob);
 		}
 		type |= CAMEL_IMAPX_COMMAND_CONTINUATION;
-		camel_object_ref(ob);
+		camel_object_ref (ob);
 		ob_size = null->written;
-		camel_object_unref((CamelObject *)null);
+		camel_object_unref (null);
 		camel_stream_printf((CamelStream *)ic->mem, "{%u}", ob_size);
 		break;
 	}
@@ -433,7 +433,7 @@ imapx_command_add_part(CamelIMAPXCommand *ic, camel_imapx_command_part_t type, g
 		CamelObject *ob = o;
 
 		/* we presume we'll need to get additional data only if we're not authenticated yet */
-		camel_object_ref(ob);
+		camel_object_ref (ob);
 		camel_stream_printf((CamelStream *)ic->mem, "%s", camel_sasl_get_mechanism (CAMEL_SASL (ob)));
 		if (!camel_sasl_get_authenticated((CamelSasl *)ob))
 			type |= CAMEL_IMAPX_COMMAND_CONTINUATION;
@@ -709,7 +709,7 @@ camel_imapx_command_free(CamelIMAPXCommand *ic)
 		return;
 
 	if (ic->mem)
-		camel_object_unref((CamelObject *)ic->mem);
+		camel_object_unref (ic->mem);
 	imapx_free_status(ic->status);
 	g_free(ic->select);
 
@@ -722,7 +722,7 @@ camel_imapx_command_free(CamelIMAPXCommand *ic)
 				g_free(cp->ob);
 				break;
 			default:
-				camel_object_unref(cp->ob);
+				camel_object_unref (cp->ob);
 			}
 		}
 		g_free(cp);
@@ -744,7 +744,7 @@ camel_imapx_command_close(CamelIMAPXCommand *ic)
 		if (byte_array->len > 0)
 			imapx_command_add_part(ic, CAMEL_IMAPX_COMMAND_SIMPLE, NULL);
 
-		camel_object_unref((CamelObject *)ic->mem);
+		camel_object_unref (ic->mem);
 		ic->mem = NULL;
 	}
 }
@@ -1206,7 +1206,7 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 				gboolean changed = FALSE;
 				gchar *uid = NULL;
 
-				camel_object_ref(imap->select_folder);
+				camel_object_ref (imap->select_folder);
 				folder = imap->select_folder;
 
 				c(printf("flag changed: %d\n", id));
@@ -1276,7 +1276,7 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex)
 				mp = camel_mime_parser_new();
 				camel_mime_parser_init_with_stream(mp, finfo->header);
 				mi = camel_folder_summary_info_new_from_parser(job->folder->summary, mp);
-				camel_object_unref(mp);
+				camel_object_unref (mp);
 
 				if (mi) {
 					guint32 server_flags;
@@ -1504,7 +1504,7 @@ imapx_continuation(CamelIMAPXServer *imap, CamelException *ex)
 		// FIXME: errors
 		if (cp->ob && (file = camel_stream_fs_new_with_name(cp->ob, O_RDONLY, 0))) {
 			camel_stream_write_to_stream(file, (CamelStream *)imap->stream);
-			camel_object_unref(file);
+			camel_object_unref (file);
 		} else if (cp->ob_size > 0) {
 			// Server is expecting data ... ummm, send it zeros?  abort?
 		}
@@ -2019,7 +2019,7 @@ imapx_command_select_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		}
 
 		if (is->select_pending)
-			camel_object_unref(is->select_pending);
+			camel_object_unref (is->select_pending);
 	} else {
 		CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) is->select_pending;
 		c(printf("Select ok!\n"));
@@ -2073,10 +2073,10 @@ imapx_select (CamelIMAPXServer *is, CamelFolder *folder, gboolean forced, CamelE
 		return;
 
 	is->select_pending = folder;
-	camel_object_ref(folder);
+	camel_object_ref (folder);
 	if (is->select_folder) {
 		g_free(is->select);
-		camel_object_unref(is->select_folder);
+		camel_object_unref (is->select_folder);
 		is->select = NULL;
 		is->select_folder = NULL;
 	}
@@ -2152,7 +2152,7 @@ imapx_connect_to_server (CamelIMAPXServer *is, CamelException *ex)
 
 	if (ex && ex->id) {
 		e(printf ("Unable to connect %d %s \n", ex->id, ex->desc));
-		camel_object_unref(tcp_stream);
+		camel_object_unref (tcp_stream);
 		return FALSE;
 	}
 
@@ -2165,12 +2165,12 @@ imapx_connect_to_server (CamelIMAPXServer *is, CamelException *ex)
 			camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
 					_("Could not connect to %s (port %s): %s"),
 					is->url->host, serv, g_strerror(errno));
-		camel_object_unref(tcp_stream);
+		camel_object_unref (tcp_stream);
 		return FALSE;
 	}
 
 	is->stream = (CamelIMAPXStream *) camel_imapx_stream_new(tcp_stream);
-	camel_object_unref(tcp_stream);
+	camel_object_unref (tcp_stream);
 
 	/* Disable Nagle - we send a lot of small requests which nagle slows down */
 	sockopt.option = CAMEL_SOCKOPT_NODELAY;
@@ -2306,7 +2306,7 @@ imapx_reconnect (CamelIMAPXServer *is, CamelException *ex)
 		if (service->url->authmech
 				&& (sasl = camel_sasl_new("imap", service->url->authmech, NULL))) {
 			ic = camel_imapx_command_new("AUTHENTICATE", NULL, "AUTHENTICATE %A", sasl);
-			camel_object_unref(sasl);
+			camel_object_unref (sasl);
 		} else {
 			ic = camel_imapx_command_new("LOGIN", NULL, "LOGIN %s %s", service->url->user, service->url->passwd);
 		}
@@ -2666,7 +2666,7 @@ imapx_command_append_message_done (CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 	g_free (old_uid);
 	camel_message_info_free(job->u.append_message.info);
 	g_free(job->u.append_message.path);
-	camel_object_unref(job->folder);
+	camel_object_unref (job->folder);
 
 	imapx_job_done (is, job);
 	camel_imapx_command_free (ic);
@@ -3846,7 +3846,7 @@ camel_imapx_server_new(CamelStore *store, CamelURL *url)
 	CamelIMAPXServer *is = (CamelIMAPXServer *)camel_object_new(camel_imapx_server_get_type());
 
 	is->session = ((CamelService *)store)->session;
-	camel_object_ref(is->session);
+	camel_object_ref (is->session);
 	is->store = store;
 	is->url = camel_url_copy(url);
 
@@ -3870,7 +3870,7 @@ imapx_disconnect (CamelIMAPXServer *is)
 
 	/* TODO need a select lock */
 	if (is->select_folder) {
-		camel_object_unref(is->select_folder);
+		camel_object_unref (is->select_folder);
 		is->select_folder = NULL;
 	}
 
@@ -3880,7 +3880,7 @@ imapx_disconnect (CamelIMAPXServer *is)
 	}
 
 	if (is->select_pending) {
-		camel_object_unref(is->select_pending);
+		camel_object_unref (is->select_pending);
 		is->select_pending = NULL;
 	}
 
@@ -4052,7 +4052,7 @@ camel_imapx_server_sync_message (CamelIMAPXServer *is, CamelFolder *folder, cons
 
 	stream = imapx_server_get_message (is, folder, NULL, uid, IMAPX_PRIORITY_SYNC_MESSAGE, ex);
 	if (stream)
-		camel_object_unref(stream);
+		camel_object_unref (stream);
 }
 
 void
@@ -4070,7 +4070,7 @@ camel_imapx_server_copy_message (CamelIMAPXServer *is, CamelFolder *source, Came
 	job->u.copy_messages.delete_originals = delete_originals;
 	job->ex = ex;
 
-	camel_object_ref(source);
+	camel_object_ref (source);
 	camel_object_ref (dest);
 
 	if (imapx_register_job (is, job))
@@ -4102,12 +4102,12 @@ camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, Cam
 	}
 
 	filter = camel_stream_filter_new (stream);
-	camel_object_unref(stream);
+	camel_object_unref (stream);
 	canon = camel_mime_filter_canon_new(CAMEL_MIME_FILTER_CANON_CRLF);
 	camel_stream_filter_add((CamelStreamFilter *)filter, canon);
 	res = camel_data_wrapper_write_to_stream((CamelDataWrapper *)message, filter);
-	camel_object_unref(canon);
-	camel_object_unref(filter);
+	camel_object_unref (canon);
+	camel_object_unref (filter);
 
 	if (res == -1) {
 		camel_exception_setv(ex, 2, "Cannot create spool file: %s", g_strerror(errno));
@@ -4132,7 +4132,7 @@ camel_imapx_server_append_message(CamelIMAPXServer *is, CamelFolder *folder, Cam
 	job->noreply = 1;
 	job->start = imapx_job_append_message_start;
 	job->folder = folder;
-	camel_object_ref(folder);
+	camel_object_ref (folder);
 	job->u.append_message.info = info;
 	job->u.append_message.path = tmp;
 
diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c
index 8bd30af..084649b 100644
--- a/camel/providers/imapx/camel-imapx-store.c
+++ b/camel/providers/imapx/camel-imapx-store.c
@@ -400,7 +400,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
 
 		if (!folder->summary)
 			camel_object_unref (ims);
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 	}
 }
 
@@ -1152,7 +1152,7 @@ imapx_refresh_free(CamelSession *session, CamelSessionThreadMsg *msg)
 {
 	struct _imapx_refresh_msg *m = (struct _imapx_refresh_msg *)msg;
 
-	camel_object_unref(m->store);
+	camel_object_unref (m->store);
 	camel_exception_clear(&m->ex);
 }
 
@@ -1211,7 +1211,7 @@ imapx_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelE
 			istore->last_refresh_time = time (NULL);
 			m = camel_session_thread_msg_new(((CamelService *)store)->session, &imapx_refresh_ops, sizeof(*m));
 			m->store = store;
-			camel_object_ref(store);
+			camel_object_ref (store);
 			camel_exception_init(&m->ex);
 			camel_session_thread_queue(((CamelService *)store)->session, &m->msg, 0);
 		}
diff --git a/camel/providers/imapx/camel-imapx-stream.c b/camel/providers/imapx/camel-imapx-stream.c
index 8622143..270747d 100644
--- a/camel/providers/imapx/camel-imapx-stream.c
+++ b/camel/providers/imapx/camel-imapx-stream.c
@@ -170,7 +170,7 @@ camel_imapx_stream_finalize(CamelIMAPXStream *is)
 {
 	g_free(is->buf);
 	if (is->source)
-		camel_object_unref((CamelObject *)is->source);
+		camel_object_unref (is->source);
 }
 
 CamelType
@@ -206,7 +206,7 @@ camel_imapx_stream_new(CamelStream *source)
 	CamelIMAPXStream *is;
 
 	is = (CamelIMAPXStream *)camel_object_new(camel_imapx_stream_get_type ());
-	camel_object_ref((CamelObject *)source);
+	camel_object_ref (source);
 	is->source = source;
 
 	return (CamelStream *)is;
@@ -380,7 +380,7 @@ camel_imapx_stream_nstring_stream(CamelIMAPXStream *is, CamelStream **stream, Ca
 			mem = camel_stream_mem_new();
 			if (camel_stream_write_to_stream((CamelStream *)is, mem) == -1) {
 				camel_exception_setv (ex, 1, "nstring: io error: %s", strerror(errno));
-				camel_object_unref((CamelObject *)mem);
+				camel_object_unref (mem);
 				ret = -1;
 				break;
 			}
diff --git a/camel/providers/imapx/camel-imapx-summary.c b/camel/providers/imapx/camel-imapx-summary.c
index 0f9204a..2db97dd 100644
--- a/camel/providers/imapx/camel-imapx-summary.c
+++ b/camel/providers/imapx/camel-imapx-summary.c
@@ -102,6 +102,9 @@ camel_imapx_summary_class_init (CamelIMAPXSummaryClass *klass)
 
 	camel_imapx_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS (camel_type_get_global_classfuncs (camel_folder_summary_get_type()));
 
+	cfs_class->message_info_size = sizeof(CamelIMAPXMessageInfo);
+	cfs_class->content_info_size = sizeof(CamelIMAPXMessageContentInfo);
+
 	cfs_class->message_info_clone = imapx_message_info_clone;
 
 	cfs_class->summary_header_load = summary_header_load;
@@ -124,11 +127,6 @@ camel_imapx_summary_class_init (CamelIMAPXSummaryClass *klass)
 static void
 camel_imapx_summary_init (CamelIMAPXSummary *obj)
 {
-	CamelFolderSummary *s = (CamelFolderSummary *)obj;
-
-	/* subclasses need to set the right instance data sizes */
-	s->message_info_size = sizeof(CamelIMAPXMessageInfo);
-	s->content_info_size = sizeof(CamelIMAPXMessageContentInfo);
 }
 
 static gint
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index f2c1211..f43f75c 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -1281,11 +1281,11 @@ imapx_free_fetch(struct _fetch_info *finfo)
 		return;
 
 	if (finfo->body)
-		camel_object_unref((CamelObject *)finfo->body);
+		camel_object_unref (finfo->body);
 	if (finfo->text)
-		camel_object_unref((CamelObject *)finfo->text);
+		camel_object_unref (finfo->text);
 	if (finfo->header)
-		camel_object_unref((CamelObject *)finfo->header);
+		camel_object_unref (finfo->header);
 	if (finfo->minfo)
 		camel_message_info_free(finfo->minfo);
 	if (finfo->cinfo)
@@ -1347,7 +1347,7 @@ imapx_dump_fetch(struct _fetch_info *finfo)
 		camel_stream_printf(sout, "Section: '%s'\n", finfo->section);
 	if (finfo->date)
 		camel_stream_printf(sout, "UID: '%s'\n", finfo->uid);
-	camel_object_unref((CamelObject *)sout);
+	camel_object_unref (sout);
 }
 
 struct _fetch_info *
diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c
index 5fbbb94..2f0a5d1 100644
--- a/camel/providers/local/camel-local-folder.c
+++ b/camel/providers/local/camel-local-folder.c
@@ -142,15 +142,15 @@ local_finalize(CamelObject * object)
 
 	if (folder->summary) {
 		camel_local_summary_sync((CamelLocalSummary *)folder->summary, FALSE, local_folder->changes, NULL);
-		camel_object_unref((CamelObject *)folder->summary);
+		camel_object_unref (folder->summary);
 		folder->summary = NULL;
 	}
 
 	if (local_folder->search)
-		camel_object_unref((CamelObject *)local_folder->search);
+		camel_object_unref (local_folder->search);
 
 	if (local_folder->index)
-		camel_object_unref((CamelObject *)local_folder->index);
+		camel_object_unref (local_folder->index);
 
 	while (local_folder->locked> 0)
 		camel_local_folder_unlock(local_folder);
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 613ad57..3ba986b 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -290,7 +290,7 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
 
 	folder = ((CamelStoreClass *)((CamelObject *)store)->klass)->get_folder(store, name, CAMEL_STORE_FOLDER_CREATE, ex);
 	if (folder) {
-		camel_object_unref((CamelObject *)folder);
+		camel_object_unref (folder);
 		info = ((CamelStoreClass *)((CamelObject *)store)->klass)->get_folder_info(store, name, 0, ex);
 
 		/* get_folder(CREATE) will emit a folder_created event for us */
@@ -405,7 +405,7 @@ ibex_failed:
 	g_free(oldibex);
 
 	if (folder)
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 }
 
 /* default implementation, only delete metadata */
diff --git a/camel/providers/local/camel-local-summary.c b/camel/providers/local/camel-local-summary.c
index 0780d99..ca24529 100644
--- a/camel/providers/local/camel-local-summary.c
+++ b/camel/providers/local/camel-local-summary.c
@@ -91,6 +91,9 @@ camel_local_summary_class_init(CamelLocalSummaryClass *klass)
 
 	camel_local_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS(camel_type_get_global_classfuncs(camel_folder_summary_get_type()));
 
+	sklass->message_info_size = sizeof(CamelLocalMessageInfo);
+	sklass->content_info_size = sizeof(CamelMessageContentInfo);
+
 	sklass->summary_header_load = summary_header_load;
 	sklass->summary_header_save = summary_header_save;
 
@@ -114,10 +117,6 @@ camel_local_summary_init(CamelLocalSummary *obj)
 {
 	struct _CamelFolderSummary *s = (CamelFolderSummary *)obj;
 
-	/* subclasses need to set the right instance data sizes */
-	s->message_info_size = sizeof(CamelLocalMessageInfo);
-	s->content_info_size = sizeof(CamelMessageContentInfo);
-
 	/* and a unique file version */
 	s->version += CAMEL_LOCAL_SUMMARY_VERSION;
 }
@@ -128,7 +127,7 @@ camel_local_summary_finalize(CamelObject *obj)
 	CamelLocalSummary *mbs = CAMEL_LOCAL_SUMMARY(obj);
 
 	if (mbs->index)
-		camel_object_unref((CamelObject *)mbs->index);
+		camel_object_unref (mbs->index);
 	g_free(mbs->folder_path);
 }
 
@@ -140,7 +139,7 @@ camel_local_summary_construct(CamelLocalSummary *new, const gchar *filename, con
 	new->folder_path = g_strdup(local_name);
 	new->index = index;
 	if (index)
-		camel_object_ref((CamelObject *)index);
+		camel_object_ref (index);
 }
 
 static gint
@@ -495,7 +494,7 @@ local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMess
 
 			camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)sn);
 			mi->info.size = sn->written;
-			camel_object_unref((CamelObject *)sn);
+			camel_object_unref (sn);
 		}
 
 		mi->info.flags &= ~(CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_FLAGGED);
diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index aedc3ee..57974b1 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -304,11 +304,11 @@ maildir_get_message(CamelFolder * folder, const gchar * uid, CamelException * ex
 	if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, message_stream) == -1) {
 		set_cannot_get_message_ex (ex, (errno==EINTR)?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM,
 				     uid, lf->folder_path, _("Invalid message contents"));
-		camel_object_unref((CamelObject *)message);
+		camel_object_unref (message);
 		message = NULL;
 
 	}
-	camel_object_unref((CamelObject *)message_stream);
+	camel_object_unref (message_stream);
  fail:
 	g_free (name);
 
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index 80436fc..942b4cb 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -306,7 +306,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
 			camel_folder_refresh_info(folder, NULL);
 		fi->unread = camel_folder_get_unread_message_count(folder);
 		fi->total = camel_folder_get_message_count(folder);
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 	} else {
 		gchar *path, *folderpath;
 		CamelFolderSummary *s;
@@ -321,7 +321,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
 			fi->unread = s->unread_count;
 			fi->total = s->saved_count;
 		}
-		camel_object_unref(s);
+		camel_object_unref (s);
 		g_free(folderpath);
 		g_free(path);
 	}
diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c
index 0fd6535..4854f51 100644
--- a/camel/providers/local/camel-maildir-summary.c
+++ b/camel/providers/local/camel-maildir-summary.c
@@ -97,6 +97,8 @@ camel_maildir_summary_class_init (CamelMaildirSummaryClass *class)
 	parent_class = (CamelLocalSummaryClass *)camel_type_get_global_classfuncs(camel_local_summary_get_type ());
 
 	/* override methods */
+	sklass->message_info_size = sizeof(CamelMaildirMessageInfo);
+	sklass->content_info_size = sizeof(CamelMaildirMessageContentInfo);
 	sklass->message_info_load = message_info_load;
 	sklass->message_info_new_from_header = message_info_new_from_header;
 	sklass->message_info_free = message_info_free;
@@ -120,9 +122,6 @@ camel_maildir_summary_init (CamelMaildirSummary *o)
 	/* set unique file version */
 	s->version += CAMEL_MAILDIR_SUMMARY_VERSION;
 
-	s->message_info_size = sizeof(CamelMaildirMessageInfo);
-	s->content_info_size = sizeof(CamelMaildirMessageContentInfo);
-
 	if (gethostname(hostname, 256) == 0) {
 		o->priv->hostname = g_strdup(hostname);
 	} else {
@@ -485,7 +484,7 @@ camel_maildir_summary_add (CamelLocalSummary *cls, const gchar *name, gint force
 	}
 	maildirs->priv->current_file = (gchar *)name;
 	camel_folder_summary_add_from_parser((CamelFolderSummary *)maildirs, mp);
-	camel_object_unref((CamelObject *)mp);
+	camel_object_unref (mp);
 	maildirs->priv->current_file = NULL;
 	camel_folder_summary_set_index((CamelFolderSummary *)maildirs, NULL);
 	g_free(filename);
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c
index eb54cbe..6102f63 100644
--- a/camel/providers/local/camel-mbox-folder.c
+++ b/camel/providers/local/camel-mbox-folder.c
@@ -439,7 +439,7 @@ retry:
 			  (glong)camel_mime_parser_tell_start_from(parser),
 			  camel_mime_parser_state(parser));
 
-		camel_object_unref((CamelObject *)parser);
+		camel_object_unref (parser);
 		parser = NULL;
 
 		if (!retried) {
@@ -459,7 +459,7 @@ retry:
 	if (camel_mime_part_construct_from_parser((CamelMimePart *)message, parser) == -1) {
 		set_cannot_get_message_ex (ex, errno==EINTR?CAMEL_EXCEPTION_USER_CANCEL:CAMEL_EXCEPTION_SYSTEM,
 				     uid, lf->folder_path, _("Message construction failed."));
-		camel_object_unref((CamelObject *)message);
+		camel_object_unref (message);
 		message = NULL;
 		goto fail;
 	}
@@ -471,7 +471,7 @@ fail:
 	camel_local_folder_unlock(lf);
 
 	if (parser)
-		camel_object_unref((CamelObject *)parser);
+		camel_object_unref (parser);
 
 	/* use the opportunity to notify of changes (particularly if we had a rebuild) */
 	if (camel_folder_change_info_changed(lf->changes)) {
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index 85026e1..b1d40fb 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -303,7 +303,7 @@ delete_folder(CamelStore *store, const gchar *folder_name, CamelException *ex)
 	if ((lf = camel_store_get_folder(store, folder_name, 0, &lex))) {
 		camel_object_get(lf, NULL, CAMEL_OBJECT_STATE_FILE, &path, NULL);
 		camel_object_set(lf, NULL, CAMEL_OBJECT_STATE_FILE, NULL, NULL);
-		camel_object_unref(lf);
+		camel_object_unref (lf);
 	} else {
 		camel_exception_clear(&lex);
 	}
@@ -395,7 +395,7 @@ create_folder(CamelStore *store, const gchar *parent_name, const gchar *folder_n
 
 	folder =((CamelStoreClass *)((CamelObject *) store)->klass)->get_folder(store, name, CAMEL_STORE_FOLDER_CREATE, ex);
 	if (folder) {
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 		info =((CamelStoreClass *)((CamelObject *) store)->klass)->get_folder_info(store, name, 0, ex);
 	}
 
@@ -543,7 +543,7 @@ rename_folder(CamelStore *store, const gchar *old, const gchar *new, CamelExcept
 	g_free(newibex);
 
 	if (folder)
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 
 	return;
 
@@ -575,7 +575,7 @@ ibex_failed:
 	g_free(oldibex);
 
 	if (folder)
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 }
 
 /* used to find out where we've visited already */
@@ -620,7 +620,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
 			camel_folder_refresh_info(folder, NULL);
 		fi->unread = camel_folder_get_unread_message_count(folder);
 		fi->total = camel_folder_get_message_count(folder);
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 	} else {
 		gchar *path, *folderpath;
 		CamelMboxSummary *mbs;
@@ -636,7 +636,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
 			fi->total = ((CamelFolderSummary *)mbs)->saved_count;
 		}
 
-		camel_object_unref(mbs);
+		camel_object_unref (mbs);
 		g_free(folderpath);
 		g_free(path);
 	}
diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c
index 64fb3a4..c5d9860 100644
--- a/camel/providers/local/camel-mbox-summary.c
+++ b/camel/providers/local/camel-mbox-summary.c
@@ -152,6 +152,9 @@ camel_mbox_summary_class_init(CamelMboxSummaryClass *klass)
 
 	camel_mbox_summary_parent = (CamelLocalSummaryClass *)camel_type_get_global_classfuncs(camel_local_summary_get_type());
 
+	sklass->message_info_size = sizeof(CamelMboxMessageInfo);
+	sklass->content_info_size = sizeof(CamelMboxMessageContentInfo);
+
 	sklass->summary_header_load = summary_header_load;
 	sklass->summary_header_save = summary_header_save;
 
@@ -189,10 +192,6 @@ camel_mbox_summary_init(CamelMboxSummary *obj)
 {
 	struct _CamelFolderSummary *s = (CamelFolderSummary *)obj;
 
-	/* subclasses need to set the right instance data sizes */
-	s->message_info_size = sizeof(CamelMboxMessageInfo);
-	s->content_info_size = sizeof(CamelMboxMessageContentInfo);
-
 	/* and a unique file version */
 	s->version += CAMEL_MBOX_SUMMARY_VERSION;
 }
@@ -579,7 +578,7 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan
 		g_assert(camel_mime_parser_step(mp, NULL, NULL) == CAMEL_MIME_PARSER_STATE_FROM_END);
 	}
 
-	camel_object_unref(CAMEL_OBJECT (mp));
+	camel_object_unref (CAMEL_OBJECT (mp));
 
 	count = camel_folder_summary_count(s);
 	for (i=0;i<count;i++) {
@@ -953,7 +952,7 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan
 
 	g_ptr_array_foreach (summary, (GFunc) camel_pstring_free, NULL);
 	g_ptr_array_free (summary, TRUE);
-	camel_object_unref((CamelObject *)mp);
+	camel_object_unref (mp);
 
 	camel_operation_end(NULL);
 
@@ -964,7 +963,7 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan
 	if (fd != -1)
 		close(fd);
 	if (mp)
-		camel_object_unref((CamelObject *)mp);
+		camel_object_unref (mp);
 	if (info)
 		camel_message_info_free((CamelMessageInfo *)info);
 
@@ -1226,7 +1225,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh
 		write(fdout, "\n", 1);
 #endif
 
-	camel_object_unref((CamelObject *)mp);
+	camel_object_unref (mp);
 
 	/* clear working flags */
 	for (i=0; i<count; i++) {
@@ -1252,7 +1251,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh
 	g_free(xevnew);
 
 	if (mp)
-		camel_object_unref((CamelObject *)mp);
+		camel_object_unref (mp);
 	if (info)
 		camel_message_info_free((CamelMessageInfo *)info);
 
diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c
index d6c226e..5214fa5 100644
--- a/camel/providers/local/camel-mh-folder.c
+++ b/camel/providers/local/camel-mh-folder.c
@@ -236,11 +236,11 @@ static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid,
 	if (camel_data_wrapper_construct_from_stream((CamelDataWrapper *)message, message_stream) == -1) {
 		set_cannot_get_message_ex (ex, CAMEL_EXCEPTION_SYSTEM,
 				      name, lf->folder_path, _("Message construction failed."));
-		camel_object_unref((CamelObject *)message);
+		camel_object_unref (message);
 		message = NULL;
 
 	}
-	camel_object_unref((CamelObject *)message_stream);
+	camel_object_unref (message_stream);
 
  fail:
 	g_free (name);
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index 22d9597..00a1774 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -125,7 +125,7 @@ folders_update(const gchar *root, gint mode, const gchar *folder, const gchar *n
 	stream = camel_stream_fs_new_with_name(tmp, O_RDONLY, 0);
 	if (stream) {
 		in = camel_stream_buffer_new(stream, CAMEL_STREAM_BUFFER_READ);
-		camel_object_unref(stream);
+		camel_object_unref (stream);
 	}
 	if (in == NULL || stream == NULL) {
 		if (mode == UPDATE_ADD && camel_stream_printf(out, "%s\n", folder) == -1)
@@ -189,9 +189,9 @@ fail:
 	unlink(tmpnew);		/* remove it if its there */
 	g_free(line);
 	if (in)
-		camel_object_unref(in);
+		camel_object_unref (in);
 	if (out)
-		camel_object_unref(out);
+		camel_object_unref (out);
 }
 
 static CamelFolder *
@@ -314,7 +314,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
 			camel_folder_refresh_info(folder, NULL);
 		fi->unread = camel_folder_get_unread_message_count(folder);
 		fi->total = camel_folder_get_message_count(folder);
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 	} else {
 		gchar *path, *folderpath;
 		CamelFolderSummary *s;
@@ -334,7 +334,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
 			fi->unread = s->unread_count;
 			fi->total = s->saved_count;
 		}
-		camel_object_unref(s);
+		camel_object_unref (s);
 		g_free(folderpath);
 		g_free(path);
 	}
@@ -460,7 +460,7 @@ folders_scan(CamelStore *store, CamelURL *url, const gchar *root, const gchar *t
 		return;
 
 	in = camel_stream_buffer_new(stream, CAMEL_STREAM_BUFFER_READ);
-	camel_object_unref(stream);
+	camel_object_unref (stream);
 	if (in == NULL)
 		return;
 
@@ -520,7 +520,7 @@ folders_scan(CamelStore *store, CamelURL *url, const gchar *root, const gchar *t
 	g_hash_table_foreach(visited, (GHFunc)g_free, NULL);
 	g_hash_table_destroy(visited);
 
-	camel_object_unref(in);
+	camel_object_unref (in);
 }
 
 /* FIXME: move to camel-local, this is shared with maildir code */
diff --git a/camel/providers/local/camel-mh-summary.c b/camel/providers/local/camel-mh-summary.c
index 3960c75..7daac74 100644
--- a/camel/providers/local/camel-mh-summary.c
+++ b/camel/providers/local/camel-mh-summary.c
@@ -196,7 +196,7 @@ static gint camel_mh_summary_add(CamelLocalSummary *cls, const gchar *name, gint
 	}
 	mhs->priv->current_uid = (gchar *)name;
 	camel_folder_summary_add_from_parser((CamelFolderSummary *)mhs, mp);
-	camel_object_unref((CamelObject *)mp);
+	camel_object_unref (mp);
 	mhs->priv->current_uid = NULL;
 	camel_folder_summary_set_index((CamelFolderSummary *)mhs, NULL);
 	g_free(filename);
diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c
index 53f8d80..87b6d7c 100644
--- a/camel/providers/local/camel-spool-store.c
+++ b/camel/providers/local/camel-spool-store.c
@@ -253,7 +253,7 @@ spool_fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags)
 			camel_folder_refresh_info(folder, NULL);
 		fi->unread = camel_folder_get_unread_message_count(folder);
 		fi->total = camel_folder_get_message_count(folder);
-		camel_object_unref(folder);
+		camel_object_unref (folder);
 	}
 }
 
@@ -376,7 +376,7 @@ static gint scan_dir(CamelStore *store, GHashTable *visited, gchar *root, const
 					spool_fill_fi(store, fi, flags);
 				}
 				if (folder)
-					camel_object_unref(folder);
+					camel_object_unref (folder);
 
 			} else if (S_ISDIR(st.st_mode)) {
 				struct _inode in = { st.st_dev, st.st_ino };
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index e879f98..88469c6 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -143,8 +143,7 @@ nntp_folder_download_message (CamelNNTPFolder *nntp_folder, const gchar *id, con
 			if (camel_stream_reset (stream) == -1)
 				goto fail;
 		} else {
-			stream = (CamelStream *) nntp_store->stream;
-			camel_object_ref (stream);
+			stream = camel_object_ref (nntp_store->stream);
 		}
 	} else if (ret == 423 || ret == 430) {
 		camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, _("Cannot get message %s: %s"), msgid, line);
@@ -234,7 +233,7 @@ nntp_folder_get_message (CamelFolder *folder, const gchar *uid, CamelException *
 			camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("User cancelled the operation"));
 		else
 			camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("Cannot get message %s: %s"), uid, g_strerror (errno));
-		camel_object_unref(message);
+		camel_object_unref (message);
 		message = NULL;
 	}
 
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index c4ef4e6..84e38cd 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -619,7 +619,7 @@ nntp_store_get_subscribed_folder_info (CamelNNTPStore *store, const gchar *top,
 						camel_object_trigger_event((CamelObject *) folder, "folder_changed", changes);
 						camel_folder_change_info_free(changes);
 					}
-					camel_object_unref(folder);
+					camel_object_unref (folder);
 				}
 				camel_exception_clear(ex);
 			}
@@ -1015,7 +1015,7 @@ nntp_store_finalize (CamelObject *object)
 	}
 
 	if (nntp_store->cache)
-		camel_object_unref(nntp_store->cache);
+		camel_object_unref (nntp_store->cache);
 
 	if (disco_store->diary) {
 		camel_object_unref (disco_store->diary);
diff --git a/camel/providers/nntp/camel-nntp-stream.c b/camel/providers/nntp/camel-nntp-stream.c
index be9204f..60c9867 100644
--- a/camel/providers/nntp/camel-nntp-stream.c
+++ b/camel/providers/nntp/camel-nntp-stream.c
@@ -218,7 +218,7 @@ camel_nntp_stream_finalize(CamelNNTPStream *is)
 	g_free(is->buf);
 	g_free(is->linebuf);
 	if (is->source)
-		camel_object_unref((CamelObject *)is->source);
+		camel_object_unref (is->source);
 }
 
 CamelType
@@ -254,8 +254,7 @@ camel_nntp_stream_new(CamelStream *source)
 	CamelNNTPStream *is;
 
 	is = (CamelNNTPStream *)camel_object_new(camel_nntp_stream_get_type ());
-	camel_object_ref((CamelObject *)source);
-	is->source = source;
+	is->source = camel_object_ref (source);
 
 	return (CamelStream *)is;
 }
diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c
index 621c8c7..f665f2e 100644
--- a/camel/providers/nntp/camel-nntp-summary.c
+++ b/camel/providers/nntp/camel-nntp-summary.c
@@ -92,6 +92,8 @@ camel_nntp_summary_class_init(CamelNNTPSummaryClass *klass)
 
 	camel_nntp_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS(camel_type_get_global_classfuncs(camel_folder_summary_get_type()));
 
+	sklass->message_info_size = sizeof(CamelMessageInfoBase);
+	sklass->content_info_size = sizeof(CamelMessageContentInfo);
 	sklass->message_info_new_from_header  = message_info_new_from_header;
 	sklass->summary_header_load = summary_header_load;
 	sklass->summary_header_save = summary_header_save;
@@ -107,10 +109,6 @@ camel_nntp_summary_init(CamelNNTPSummary *obj)
 
 	p = _PRIVATE(obj) = g_malloc0(sizeof(*p));
 
-	/* subclasses need to set the right instance data sizes */
-	s->message_info_size = sizeof(CamelMessageInfoBase);
-	s->content_info_size = sizeof(CamelMessageContentInfo);
-
 	/* and a unique file version */
 	s->version += CAMEL_NNTP_SUMMARY_VERSION;
 }
@@ -421,7 +419,7 @@ ioerror:
 		g_free(cns->priv->uid);
 		cns->priv->uid = NULL;
 	}
-	camel_object_unref((CamelObject *)mp);
+	camel_object_unref (mp);
 
 	camel_operation_end(NULL);
 
diff --git a/camel/providers/pop3/camel-pop3-engine.c b/camel/providers/pop3/camel-pop3-engine.c
index eea2c50..1853e8f 100644
--- a/camel/providers/pop3/camel-pop3-engine.c
+++ b/camel/providers/pop3/camel-pop3-engine.c
@@ -73,7 +73,7 @@ camel_pop3_engine_finalize(CamelPOP3Engine *pe)
 	/* FIXME: Also flush/free any outstanding requests, etc */
 
 	if (pe->stream)
-		camel_object_unref(pe->stream);
+		camel_object_unref (pe->stream);
 
 	g_list_free(pe->auth);
 	if (pe->apop)
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 7a193ca..6f9c84d 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -170,7 +170,7 @@ cmd_builduid(CamelPOP3Engine *pe, CamelPOP3Stream *stream, gpointer data)
 	default:
 		break;
 	}
-	camel_object_unref(mp);
+	camel_object_unref (mp);
 	g_checksum_get_digest (checksum, digest, &length);
 	g_checksum_free (checksum);
 
@@ -380,7 +380,7 @@ pop3_get_message_time_from_cache (CamelFolder *folder, const gchar *uid, time_t
 		message = camel_mime_message_new ();
 		if (camel_data_wrapper_construct_from_stream ((CamelDataWrapper *)message, stream) == -1) {
 			g_warning (_("Cannot get message %s: %s"), uid, g_strerror (errno));
-			camel_object_unref ((CamelObject *)message);
+			camel_object_unref (message);
 			message = NULL;
 		}
 
@@ -388,7 +388,7 @@ pop3_get_message_time_from_cache (CamelFolder *folder, const gchar *uid, time_t
 			res = TRUE;
 			*message_time = message->date + message->date_offset;
 
-			camel_object_unref ((CamelObject *)message);
+			camel_object_unref (message);
 		}
 	}
 
@@ -422,7 +422,7 @@ camel_pop3_delete_old(CamelFolder *folder, gint days_to_delete,	CamelException *
 			message = pop3_get_message (folder, fi->uid, ex);
 			if (message) {
 				message_time = message->date + message->date_offset;
-				camel_object_unref(message);
+				camel_object_unref (message);
 			}
 		}
 
@@ -516,7 +516,7 @@ done:
 		fi->err = 0;
 	}
 
-	camel_object_unref((CamelObject *)fi->stream);
+	camel_object_unref (fi->stream);
 	fi->stream = NULL;
 }
 
@@ -599,8 +599,7 @@ pop3_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
 			stream = camel_stream_mem_new();
 
 		/* ref it, the cache storage routine unref's when done */
-		camel_object_ref((CamelObject *)stream);
-		fi->stream = stream;
+		fi->stream = camel_object_ref (stream);
 		fi->err = EIO;
 		pcr = camel_pop3_engine_command_new(pop3_store->engine, CAMEL_POP3_COMMAND_MULTI, cmd_tocache, fi, "RETR %u\r\n", fi->id);
 
@@ -662,11 +661,11 @@ pop3_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
 			camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
 				_("Cannot get message %s: %s"),
 				uid, g_strerror (errno));
-		camel_object_unref((CamelObject *)message);
+		camel_object_unref (message);
 		message = NULL;
 	}
 done:
-	camel_object_unref((CamelObject *)stream);
+	camel_object_unref (stream);
 fail:
 	camel_operation_end(NULL);
 
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index 0ff3b83..34c10cb 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -123,9 +123,9 @@ finalize (CamelObject *object)
 	camel_service_disconnect((CamelService *)pop3_store, TRUE, NULL);
 
 	if (pop3_store->engine)
-		camel_object_unref((CamelObject *)pop3_store->engine);
+		camel_object_unref (pop3_store->engine);
 	if (pop3_store->cache)
-		camel_object_unref((CamelObject *)pop3_store->cache);
+		camel_object_unref (pop3_store->cache);
 }
 
 enum {
@@ -460,7 +460,7 @@ try_sasl(CamelPOP3Store *store, const gchar *mech, CamelException *ex)
 			goto ioerror;
 
 	}
-	camel_object_unref((CamelObject *)sasl);
+	camel_object_unref (sasl);
 	return 0;
 
  ioerror:
@@ -472,7 +472,7 @@ try_sasl(CamelPOP3Store *store, const gchar *mech, CamelException *ex)
 				      CAMEL_SERVICE (store)->url->host, g_strerror (errno));
 	}
  done:
-	camel_object_unref((CamelObject *)sasl);
+	camel_object_unref (sasl);
 	return -1;
 }
 
@@ -683,7 +683,7 @@ pop3_disconnect (CamelService *service, gboolean clean, CamelException *ex)
 	if (!CAMEL_SERVICE_CLASS (parent_class)->disconnect (service, clean, ex))
 		return FALSE;
 
-	camel_object_unref((CamelObject *)store->engine);
+	camel_object_unref (store->engine);
 	store->engine = NULL;
 
 	return TRUE;
diff --git a/camel/providers/pop3/camel-pop3-stream.c b/camel/providers/pop3/camel-pop3-stream.c
index 5f3d8be..c8264ec 100644
--- a/camel/providers/pop3/camel-pop3-stream.c
+++ b/camel/providers/pop3/camel-pop3-stream.c
@@ -221,7 +221,7 @@ camel_pop3_stream_finalize(CamelPOP3Stream *is)
 	g_free(is->buf);
 	g_free(is->linebuf);
 	if (is->source)
-		camel_object_unref((CamelObject *)is->source);
+		camel_object_unref (is->source);
 }
 
 CamelType
@@ -257,8 +257,7 @@ camel_pop3_stream_new(CamelStream *source)
 	CamelPOP3Stream *is;
 
 	is = (CamelPOP3Stream *)camel_object_new(camel_pop3_stream_get_type ());
-	camel_object_ref((CamelObject *)source);
-	is->source = source;
+	is->source = camel_object_ref (source);
 
 	return (CamelStream *)is;
 }
diff --git a/camel/tests/folder/test1.c b/camel/tests/folder/test1.c
index 87684eb..d8b86e0 100644
--- a/camel/tests/folder/test1.c
+++ b/camel/tests/folder/test1.c
@@ -43,7 +43,7 @@ gint main(gint argc, gchar **argv)
 		g_free(path);
 	}
 
-	camel_object_unref((CamelObject *)session);
+	camel_object_unref (session);
 	camel_exception_free(ex);
 
 	return 0;
diff --git a/camel/tests/folder/test10.c b/camel/tests/folder/test10.c
index b56c707..1cc00e1 100644
--- a/camel/tests/folder/test10.c
+++ b/camel/tests/folder/test10.c
@@ -39,11 +39,11 @@ worker(gpointer d)
 		folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex);
 		camel_exception_clear(ex);
 		if (testid == 0) {
-			camel_object_unref(folder);
-			camel_object_unref(store);
+			camel_object_unref (folder);
+			camel_object_unref (store);
 		} else {
-			camel_object_unref(store);
-			camel_object_unref(folder);
+			camel_object_unref (store);
+			camel_object_unref (folder);
 		}
 	}
 
@@ -93,7 +93,7 @@ gint main(gint argc, gchar **argv)
 		camel_test_end();
 	}
 
-	camel_object_unref((CamelObject *)session);
+	camel_object_unref (session);
 	camel_exception_free(ex);
 
 	return 0;
diff --git a/camel/tests/folder/test4.c b/camel/tests/folder/test4.c
index 875707e..60123fd 100644
--- a/camel/tests/folder/test4.c
+++ b/camel/tests/folder/test4.c
@@ -44,7 +44,7 @@ gint main(gint argc, gchar **argv)
 		/*camel_test_fatal();*/
 	}
 
-	camel_object_unref((CamelObject *)session);
+	camel_object_unref (session);
 	camel_exception_free(ex);
 
 	return 0;
diff --git a/camel/tests/folder/test5.c b/camel/tests/folder/test5.c
index 0d38027..e1412f5 100644
--- a/camel/tests/folder/test5.c
+++ b/camel/tests/folder/test5.c
@@ -44,7 +44,7 @@ gint main(gint argc, gchar **argv)
 		camel_test_fatal();
 	}
 
-	camel_object_unref((CamelObject *)session);
+	camel_object_unref (session);
 	camel_exception_free(ex);
 
 	return 0;
diff --git a/camel/tests/folder/test8.c b/camel/tests/folder/test8.c
index 17e7902..1368d18 100644
--- a/camel/tests/folder/test8.c
+++ b/camel/tests/folder/test8.c
@@ -196,7 +196,7 @@ gint main(gint argc, gchar **argv)
 		}
 	}
 
-	camel_object_unref((CamelObject *)session);
+	camel_object_unref (session);
 	camel_exception_free(ex);
 
 	return 0;
diff --git a/camel/tests/folder/test9.c b/camel/tests/folder/test9.c
index fdc8ea6..1e7d377 100644
--- a/camel/tests/folder/test9.c
+++ b/camel/tests/folder/test9.c
@@ -71,8 +71,7 @@ static CamelFolder *get_folder(CamelFilterDriver *d, const gchar *uri, gpointer
 
 	for (i = 0; i < G_N_ELEMENTS (mailboxes); i++)
 		if (!strcmp(mailboxes[i].name, uri)) {
-			camel_object_ref((CamelObject *)mailboxes[i].folder);
-			return mailboxes[i].folder;
+			return camel_object_ref (mailboxes[i].folder);
 		}
 	return NULL;
 }
diff --git a/camel/tests/lib/camel-test.h b/camel/tests/lib/camel-test.h
index e942a95..ca4a5eb 100644
--- a/camel/tests/lib/camel-test.h
+++ b/camel/tests/lib/camel-test.h
@@ -34,7 +34,7 @@ static void check_msg(gint truth, gchar *fmt, ...)
 
 #define check_unref(object, expected) do { \
 	check_count(object, expected); \
-	camel_object_unref(CAMEL_OBJECT(object)); \
+	camel_object_unref (CAMEL_OBJECT(object)); \
 	if (expected == 1) { \
 		object = NULL; \
 	} \
diff --git a/camel/tests/lib/folders.c b/camel/tests/lib/folders.c
index da659a3..4c23c43 100644
--- a/camel/tests/lib/folders.c
+++ b/camel/tests/lib/folders.c
@@ -105,7 +105,7 @@ test_folder_message(CamelFolder *folder, const gchar *uid)
 	/* cross check with info */
 	test_message_info(msg, info);
 
-	camel_object_unref((CamelObject *)msg);
+	camel_object_unref (msg);
 
 	/* see if it is in the summary (only once) */
 	s = camel_folder_get_summary(folder);
diff --git a/camel/tests/lib/messages.c b/camel/tests/lib/messages.c
index 3060ee1..2523f9a 100644
--- a/camel/tests/lib/messages.c
+++ b/camel/tests/lib/messages.c
@@ -96,7 +96,7 @@ test_message_write_file(CamelMimeMessage *msg, const gchar *name)
 	ret = camel_stream_close((CamelStream *)file);
 
 	check(((CamelObject *)file)->ref_count == 1);
-	camel_object_unref((CamelObject *)file);
+	camel_object_unref (file);
 
 	return ret;
 }
@@ -113,7 +113,7 @@ test_message_read_file(const gchar *name)
 	camel_data_wrapper_construct_from_stream((CamelDataWrapper *)msg2, (CamelStream *)file);
 	/* file's refcount may be > 1 if the message is real big */
 	check(CAMEL_OBJECT(file)->ref_count >=1);
-	camel_object_unref((CamelObject *)file);
+	camel_object_unref (file);
 
 	return msg2;
 }
diff --git a/camel/tests/smime/pgp.c b/camel/tests/smime/pgp.c
index efe8772..23de0d9 100644
--- a/camel/tests/smime/pgp.c
+++ b/camel/tests/smime/pgp.c
@@ -159,8 +159,8 @@ gint main (gint argc, gchar **argv)
 	dw = camel_data_wrapper_new();
 	camel_data_wrapper_construct_from_stream(dw, stream1);
 	camel_medium_set_content ((CamelMedium *)conpart, dw);
-	camel_object_unref(stream1);
-	camel_object_unref(dw);
+	camel_object_unref (stream1);
+	camel_object_unref (dw);
 
 	sigpart = camel_mime_part_new();
 
@@ -182,8 +182,8 @@ gint main (gint argc, gchar **argv)
 	camel_cipher_validity_free (valid);
 	camel_test_pull ();
 
-	camel_object_unref(conpart);
-	camel_object_unref(sigpart);
+	camel_object_unref (conpart);
+	camel_object_unref (sigpart);
 
 	stream1 = camel_stream_mem_new ();
 	camel_stream_write (stream1, "Hello, I am a test of encryption/decryption.", 44);
@@ -194,8 +194,8 @@ gint main (gint argc, gchar **argv)
 	camel_stream_reset(stream1);
 	camel_data_wrapper_construct_from_stream(dw, stream1);
 	camel_medium_set_content ((CamelMedium *)conpart, dw);
-	camel_object_unref(stream1);
-	camel_object_unref(dw);
+	camel_object_unref (stream1);
+	camel_object_unref (dw);
 
 	encpart = camel_mime_part_new();
 
@@ -231,11 +231,11 @@ gint main (gint argc, gchar **argv)
 	g_free (before);
 	g_free (after);
 
-	camel_object_unref(stream1);
-	camel_object_unref(stream2);
-	camel_object_unref(conpart);
-	camel_object_unref(encpart);
-	camel_object_unref(outpart);
+	camel_object_unref (stream1);
+	camel_object_unref (stream2);
+	camel_object_unref (conpart);
+	camel_object_unref (encpart);
+	camel_object_unref (outpart);
 
 	camel_test_pull ();
 
diff --git a/docs/reference/camel/tmpl/camel-folder-summary.sgml b/docs/reference/camel/tmpl/camel-folder-summary.sgml
index 1269637..383e5f0 100644
--- a/docs/reference/camel/tmpl/camel-folder-summary.sgml
+++ b/docs/reference/camel/tmpl/camel-folder-summary.sgml
@@ -34,8 +34,6 @@ CamelFolderSummary
 @junk_count: 
 @junk_not_deleted_count: 
 @visible_count: 
- message_info_size: 
- content_info_size: 
 @message_info_chunks: 
 @content_info_chunks: 
 @summary_path: 
diff --git a/docs/reference/camel/tmpl/camel-mime-part.sgml b/docs/reference/camel/tmpl/camel-mime-part.sgml
index 3fbaa9b..e4992a9 100644
--- a/docs/reference/camel/tmpl/camel-mime-part.sgml
+++ b/docs/reference/camel/tmpl/camel-mime-part.sgml
@@ -23,14 +23,8 @@ CamelMimePart
 </para>
 
 @parent: 
+ priv: 
 @headers: 
- description: 
- disposition: 
- content_id: 
- content_MD5: 
- content_location: 
- content_languages: 
- encoding: 
 
 <!-- ##### FUNCTION camel_mime_part_new ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-object.sgml b/docs/reference/camel/tmpl/camel-object.sgml
index 6178fb9..8fa5e01 100644
--- a/docs/reference/camel/tmpl/camel-object.sgml
+++ b/docs/reference/camel/tmpl/camel-object.sgml
@@ -290,6 +290,7 @@ CamelObject
 </para>
 
 @Param1: 
+ Returns: 
 
 
 <!-- ##### FUNCTION camel_object_unref ##### -->
diff --git a/docs/reference/camel/tmpl/camel-stream-buffer.sgml b/docs/reference/camel/tmpl/camel-stream-buffer.sgml
index 9782e2e..9d4395c 100644
--- a/docs/reference/camel/tmpl/camel-stream-buffer.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-buffer.sgml
@@ -23,15 +23,7 @@ CamelStreamBuffer
 </para>
 
 @parent: 
- stream: 
- buf: 
- ptr: 
- end: 
- size: 
- linebuf: 
- linesize: 
- mode: 
- flags: 
+ priv: 
 
 <!-- ##### ENUM CamelStreamBufferMode ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream-filter.sgml b/docs/reference/camel/tmpl/camel-stream-filter.sgml
index 790b1b4..c2ef473 100644
--- a/docs/reference/camel/tmpl/camel-stream-filter.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-filter.sgml
@@ -23,7 +23,6 @@ CamelStreamFilter
 </para>
 
 @parent: 
- source: 
 @priv: 
 
 <!-- ##### FUNCTION camel_stream_filter_add ##### -->
diff --git a/docs/reference/camel/tmpl/camel-stream-fs.sgml b/docs/reference/camel/tmpl/camel-stream-fs.sgml
index 4abf2ca..9d1ac55 100644
--- a/docs/reference/camel/tmpl/camel-stream-fs.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-fs.sgml
@@ -23,7 +23,7 @@ CamelStreamFs
 </para>
 
 @parent: 
- fd: 
+ priv: 
 
 <!-- ##### FUNCTION camel_stream_fs_new_with_name ##### -->
 <para>
diff --git a/docs/reference/camel/tmpl/camel-stream-mem.sgml b/docs/reference/camel/tmpl/camel-stream-mem.sgml
index d7a63a1..2255f8f 100644
--- a/docs/reference/camel/tmpl/camel-stream-mem.sgml
+++ b/docs/reference/camel/tmpl/camel-stream-mem.sgml
@@ -23,9 +23,7 @@ CamelStreamMem
 </para>
 
 @parent: 
- owner: 
- secure: 
- buffer: 
+ priv: 
 
 <!-- ##### FUNCTION camel_stream_mem_new ##### -->
 <para>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]