[Xfce4-commits] <squeeze:peter/refactoring> libqueeze code review and refactoring

Peter de Ridder noreply at xfce.org
Thu Dec 22 23:14:02 CET 2011


Updating branch refs/heads/peter/refactoring
         to f2e128c8a48e7e5cafd600ecee3a7af7b4e2395b (commit)
       from 411ec7293971367a99476ecb1f23437ebd07bc60 (commit)

commit f2e128c8a48e7e5cafd600ecee3a7af7b4e2395b
Author: Peter de Ridder <peter at xfce.org>
Date:   Thu Dec 22 23:07:26 2011 +0100

    libqueeze code review and refactoring

 libsqueeze/archive-iter-pool.c |  304 +++--
 libsqueeze/archive-iter-pool.h |   38 +-
 libsqueeze/archive-iter.c      | 2828 ++++++++++++++++++++++------------------
 libsqueeze/archive-iter.h      |   80 +-
 libsqueeze/archive-tempfs.c    |  128 +-
 libsqueeze/archive-tempfs.h    |   17 +-
 libsqueeze/archive.c           |  437 ++++---
 libsqueeze/archive.h           |  123 +-
 libsqueeze/btree.c             |   37 +-
 libsqueeze/btree.h             |   10 +-
 libsqueeze/command-option.c    |  454 ++++---
 libsqueeze/command-option.h    |   82 +-
 libsqueeze/command-queue.c     | 1120 +++++++++--------
 libsqueeze/command-queue.h     |   51 +-
 libsqueeze/datetime.c          |   36 +-
 libsqueeze/datetime.h          |   18 +-
 libsqueeze/internals.c         |   46 +-
 libsqueeze/internals.h         |   15 +-
 libsqueeze/libsqueeze-view.h   |   47 +-
 libsqueeze/libsqueeze.c        |  224 ++--
 libsqueeze/libsqueeze.h        |   28 +-
 libsqueeze/parser-context.c    |   53 +-
 libsqueeze/parser-context.h    |   38 +-
 libsqueeze/parser.c            |  144 ++-
 libsqueeze/parser.h            |   58 +-
 libsqueeze/pcre-parser.c       |  156 ++-
 libsqueeze/pcre-parser.h       |   33 +-
 libsqueeze/scanf-parser.c      |  419 ++++---
 libsqueeze/scanf-parser.h      |   40 +-
 libsqueeze/support-factory.c   |  100 +-
 libsqueeze/support-factory.h   |   55 +-
 libsqueeze/support-reader.c    |  473 ++++----
 libsqueeze/support-reader.h    |   38 +-
 libsqueeze/support-template.c  |   50 +-
 libsqueeze/support-template.h  |   15 +-
 src/application.h              |    4 +-
 src/archive_store.c            |    4 +-
 src/archive_store.h            |    8 +-
 src/button_drag_box.c          |    4 +-
 src/button_drag_box.h          |    4 +-
 src/extract_dialog.h           |    8 +-
 src/main_window.c              |   36 +-
 src/main_window.h              |    8 +-
 src/message_dialog.c           |    2 +-
 src/message_dialog.h           |    8 +-
 src/navigation_bar.h           |    4 +-
 src/new_dialog.h               |    8 +-
 src/notebook.h                 |    8 +-
 src/path_bar.c                 |   12 +-
 src/path_bar.h                 |    4 +-
 src/preferences_dialog.h       |    8 +-
 src/properties_dialog.h        |    8 +-
 src/settings.h                 |    8 +-
 src/throbber.c                 |    2 +-
 src/tool_bar.c                 |   10 +-
 src/tool_bar.h                 |    4 +-
 src/widget_factory.c           |   50 +-
 57 files changed, 4477 insertions(+), 3530 deletions(-)

diff --git a/libsqueeze/archive-iter-pool.c b/libsqueeze/archive-iter-pool.c
index c36eb34..310efe8 100644
--- a/libsqueeze/archive-iter-pool.c
+++ b/libsqueeze/archive-iter-pool.c
@@ -30,177 +30,229 @@
 
 struct _LSQArchiveIterPool
 {
-	LSQArchiveIter **pool;
-	guint size;
-	guint reserved;
+    LSQArchiveIter **pool;
+    guint size;
+    guint reserved;
 };
 
 LSQArchiveIterPool *
-lsq_archive_iter_pool_new(void)
+lsq_archive_iter_pool_new ( void )
 {
-	return g_new0(LSQArchiveIterPool, 1);
+    return g_new0( LSQArchiveIterPool, 1 );
 }
 
 void
-lsq_archive_iter_pool_free(LSQArchiveIterPool *pool)
+lsq_archive_iter_pool_free ( LSQArchiveIterPool *pool )
 {
-	/* lsq_archive_iter_pool_print();*/
-	/* free the pool of iters */
-	guint i;
-	for(i = 0; i < pool->size; ++i)
-	{
-		lsq_archive_iter_unref(pool->pool[i]);
-	}
-	for(i = 0; i < pool->size; ++i)
-	{
+    /* lsq_archive_iter_pool_print();*/
+    /* free the pool of iters */
+    guint i;
+
+    g_return_if_fail( NULL != pool );
+
+    for ( i = 0; i < pool->size; ++i )
+    {
+        lsq_archive_iter_unref( pool->pool[i] );
+    }
+    for ( i = 0; i < pool->size; ++i )
+    {
 #ifdef USE_LSQITER_SLICES
-		/* Cleaning up the whole pool */
-		/* Now we can free the iters  */
+        /* Cleaning up the whole pool */
+        /* Now we can free the iters  */
 #ifdef USE_GSLICES
-		g_slice_free(LSQArchiveIter, pool->pool[i]);
+        g_slice_free( LSQArchiveIter, pool->pool[i] );
 #else
-		g_free(pool->pool[i]);
+        g_free( pool->pool[i] );
 #endif
 #elif defined(USE_GSLICES)
-		g_slice_free(LSQArchiveIter, pool->pool[i]);
+        g_slice_free( LSQArchiveIter, pool->pool[i] );
 #else
-		g_free(pool->pool[i]);
+        g_free( pool->pool[i] );
 #endif
-	}
+    }
 #ifdef USE_LSQITER_SLICES
-	for(; i < pool->reserved; ++i)
-	{
-		/* Cleaning up the whole pool */
-		/* Now we can free the iters  */
-		if(!pool->pool[i])
-			break;
+    for ( ; i < pool->reserved; ++i )
+    {
+        /* Cleaning up the whole pool */
+        /* Now we can free the iters  */
+        if ( NULL == pool->pool[i] )
+        {
+            break;
+        }
 #ifdef USE_GSLICES
-		g_slice_free(LSQArchiveIter, pool->pool[i]);
+        g_slice_free( LSQArchiveIter, pool->pool[i] );
 #else
-		g_free(pool->pool[i]);
+        g_free( pool->pool[i] );
 #endif
-	}
+    }
 #endif
-	g_free(pool->pool);
-	g_free(pool);
+    g_free( pool->pool );
+    g_free( pool );
 }
 
 gboolean
-lsq_archive_iter_pool_find_iter(LSQArchiveIterPool *ipool, LSQArchiveEntry *entry, LSQArchiveIter **ret_iter, guint *ret_pos)
+lsq_archive_iter_pool_find_iter ( LSQArchiveIterPool *ipool, LSQArchiveEntry *entry, LSQArchiveIter **ret_iter, guint *ret_pos )
 {
-	/* binary search */
-	LSQArchiveIter **pool = ipool->pool;
-	guint size = ipool->size;
-	guint pos;
-	guint off = 0;
-	gintptr cmp;
-	while(size)
-	{
-		pos = size / 2;
-		cmp = (guintptr)entry - (guintptr)pool[off+pos]->entry;
-		if(cmp == 0)
-		{
-			if(ret_iter)
-				(*ret_iter) = pool[off+pos];
-			if(ret_pos)
-				(*ret_pos) = off+pos;
-			return TRUE;
-		}
-		if(cmp > 0)
-		{
-			size -= ++pos;
-			off += pos;
-		}
-		if(cmp < 0)
-		{
-			size = pos;
-		}
-	}
-	if(ret_pos)
-		(*ret_pos) = off;
-	return FALSE;
+    /* binary search */
+    LSQArchiveIter **pool = ipool->pool;
+    guint size = ipool->size;
+    guint pos;
+    guint off = 0;
+    gintptr cmp;
+
+#if DEBUG
+    g_return_val_if_fail( NULL != ipool, FALSE );
+    g_return_val_if_fail( NULL != entry, FALSE );
+#endif
+
+    while ( 0 < size )
+    {
+        pos = size / 2;
+        cmp = (guintptr)entry - (guintptr)pool[off+pos]->entry;
+        if ( cmp == 0 )
+        {
+            if ( NULL != ret_iter )
+            {
+                (*ret_iter) = pool[off+pos];
+            }
+            if ( NULL != ret_pos )
+            {
+                (*ret_pos) = off+pos;
+            }
+            return TRUE;
+        }
+        if ( 0 < cmp )
+        {
+            size -= ++pos;
+            off += pos;
+        }
+        if ( 0 > cmp )
+        {
+            size = pos;
+        }
+    }
+    if ( NULL != ret_pos )
+    {
+        (*ret_pos) = off;
+    }
+    return FALSE;
 }
 
 void
-lsq_archive_iter_pool_insert_iter(LSQArchiveIterPool *ipool, LSQArchiveIter *iter, guint pos)
+lsq_archive_iter_pool_insert_iter ( LSQArchiveIterPool *ipool, LSQArchiveIter *iter, guint pos )
 {
-	LSQArchiveIter **pool, **old_pool = pool = ipool->pool;
-	guint i;
-
-	/* make space for new iter */
-	if(ipool->size >= ipool->reserved)
-	{
-		pool = g_new(LSQArchiveIter*, ipool->reserved + ipool->size + 1);
-		for(i = 0; i < pos; ++i)
-		{
-			pool[i] = old_pool[i];
-		}
-	}
-
-	/* move all behind the iter */
-	for(i = ipool->size; i > pos; --i)
-	{
-		pool[i] = old_pool[i-1];
-	}
-
-	/* finish up the new pool */
-	ipool->size++;
-	if(ipool->size > ipool->reserved)
-	{
-		ipool->reserved += ipool->size;
-		ipool->pool = pool;
-		g_free(old_pool);
+    LSQArchiveIter **pool, **old_pool = pool = ipool->pool;
+    guint i;
+
+#if DEBUG
+    g_return_if_fail( NULL != ipool );
+    g_return_if_fail( NULL != iter );
+    g_return_if_fail( ipool->size >= pos );
+#endif
+
+    /* make space for new iter */
+    if ( ipool->size >= ipool->reserved )
+    {
+        pool = g_new( LSQArchiveIter *, ipool->reserved + ipool->size + 1 );
+        for ( i = 0; i < pos; ++i )
+        {
+            pool[i] = old_pool[i];
+        }
+    }
+
 #ifdef USE_LSQITER_SLICES
-		/* We need to know if there are still allocations left */
-		/* Make all unallocated NULL						   */
-		for(i = ipool->size; i < ipool->reserved; ++i)
-		{
-			pool[i] = NULL;
-		}
+    /* If we USE_LSQITER_SLICES we overwrite the first reserved pointer.
+     * But we just picked that one out of the pool and use that as our current iter.
+     */
+#ifdef PADENTIC
+    g_return_if_fail( NULL == old_pool[ipool->size] || old_pool[ipool->size] == iter );
 #endif
-	}
+#endif
+    /* move all behind the iter */
+    for ( i = ipool->size; i > pos; --i )
+    {
+        pool[i] = old_pool[i-1];
+    }
 
-	/* insert the iter */
-	pool[pos] = iter;
+    /* finish up the new pool */
+    ipool->size++;
+    if ( ipool->size > ipool->reserved )
+    {
+        ipool->reserved += ipool->size;
+        ipool->pool = pool;
+        g_free( old_pool );
+#ifdef USE_LSQITER_SLICES
+        /* We need to know if there are still allocations left */
+        /* Make all unallocated NULL                           */
+        for ( i = ipool->size; i < ipool->reserved; ++i )
+        {
+            pool[i] = NULL;
+        }
+#endif
+    }
+
+    /* insert the iter */
+    pool[pos] = iter;
 }
 
 void
-lsq_archive_iter_pool_remove_iter(LSQArchiveIterPool *ipool, LSQArchiveIter *iter)
+lsq_archive_iter_pool_remove_iter ( LSQArchiveIterPool *ipool, LSQArchiveIter *iter )
 {
-	LSQArchiveIter **pool = ipool->pool;
-	guint pos;
-
-	/* iter has been found (should allways) */
-	if(G_LIKELY(lsq_archive_iter_pool_find_iter(ipool, iter->entry, NULL, &pos)))
-	{
-		ipool->size--;
-
-		for(; pos < ipool->size; ++pos)
-		{
-			pool[pos] = pool[pos+1];
-		}
+    LSQArchiveIter **pool = ipool->pool;
+    guint pos;
+
+#if DEBUG
+    g_return_if_fail( NULL != ipool );
+    g_return_if_fail( NULL != iter );
+#endif
+
+    /* iter has been found (should allways) */
+    if ( G_LIKELY ( TRUE == lsq_archive_iter_pool_find_iter(ipool, iter->entry, NULL, &pos ) ) )
+    {
+        ipool->size--;
+
+        for ( ; pos < ipool->size; ++pos )
+        {
+            pool[pos] = pool[pos+1];
+        }
 #ifdef USE_LSQITER_SLICES
-		/* We don't free the pointer so move it */
-		/* Place it at the end om the pool	  */
-		pool[ipool->size] = iter;
+        /* We don't free the pointer so move it */
+        /* Place it at the end om the pool	  */
+        pool[ipool->size] = iter;
+#endif
+    }
+#if DEBUG
+    else
+    {
+        g_return_if_reached();
+    }
 #endif
-	}
 }
 
-gint
-lsq_archive_iter_pool_get_size(LSQArchiveIterPool *pool)
+guint
+lsq_archive_iter_pool_get_size ( LSQArchiveIterPool *pool )
 {
-	return pool->size;
+#if DEBUG
+    g_return_val_if_fail( NULL != pool, 0 );
+#endif
+    return pool->size;
 }
 
-gint
-lsq_archive_iter_pool_get_reserved(LSQArchiveIterPool *pool)
+guint
+lsq_archive_iter_pool_get_reserved ( LSQArchiveIterPool *pool )
 {
-	return pool->reserved;
+#if DEBUG
+    g_return_val_if_fail( NULL != pool, 0 );
+#endif
+    return pool->reserved;
 }
 
 LSQArchiveIter *
-lsq_archive_iter_pool_get_iter(LSQArchiveIterPool *pool, gint index_)
+lsq_archive_iter_pool_get_iter ( LSQArchiveIterPool *pool, guint index_ )
 {
-	return pool->pool[index_];
+#if DEBUG
+    g_return_val_if_fail( NULL != pool, NULL );
+    g_return_val_if_fail( pool->reserved > index_, NULL );
+#endif
+    return pool->pool[index_];
 }
diff --git a/libsqueeze/archive-iter-pool.h b/libsqueeze/archive-iter-pool.h
index 715cd61..31315bb 100644
--- a/libsqueeze/archive-iter-pool.h
+++ b/libsqueeze/archive-iter-pool.h
@@ -21,20 +21,40 @@ typedef struct _LSQArchiveIter LSQArchiveIter;
 typedef struct _LSQArchiveEntry LSQArchiveEntry;
 typedef struct _LSQArchiveIterPool LSQArchiveIterPool;
 
-LSQArchiveIterPool *lsq_archive_iter_pool_new(void);
-void				lsq_archive_iter_pool_free(LSQArchiveIterPool *pool);
+LSQArchiveIterPool *
+lsq_archive_iter_pool_new ( void ) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+void
+lsq_archive_iter_pool_free ( LSQArchiveIterPool *pool );
 
-gint				lsq_archive_iter_pool_get_size(LSQArchiveIterPool *);
-gint				lsq_archive_iter_pool_get_reserved(LSQArchiveIterPool *);
-LSQArchiveIter	 *lsq_archive_iter_pool_get_iter(LSQArchiveIterPool *, gint index);
+guint
+lsq_archive_iter_pool_get_size ( LSQArchiveIterPool * ) G_GNUC_PURE;
+guint
+lsq_archive_iter_pool_get_reserved ( LSQArchiveIterPool * ) G_GNUC_PURE;
+LSQArchiveIter *
+lsq_archive_iter_pool_get_iter (
+        LSQArchiveIterPool *,
+        guint index
+    );
 
 gboolean
-lsq_archive_iter_pool_find_iter(LSQArchiveIterPool *ipool, LSQArchiveEntry *entry, LSQArchiveIter **ret_iter, guint *ret_pos);
+lsq_archive_iter_pool_find_iter (
+        LSQArchiveIterPool *ipool,
+        LSQArchiveEntry *entry,
+        LSQArchiveIter **ret_iter,
+        guint *ret_pos
+    );
 void
-lsq_archive_iter_pool_insert_iter(LSQArchiveIterPool *ipool, LSQArchiveIter *iter, guint pos);
+lsq_archive_iter_pool_insert_iter (
+        LSQArchiveIterPool *ipool,
+        LSQArchiveIter *iter,
+        guint pos
+    );
 void
-lsq_archive_iter_pool_remove_iter(LSQArchiveIterPool *ipool, LSQArchiveIter *iter);
+lsq_archive_iter_pool_remove_iter (
+        LSQArchiveIterPool *ipool,
+        LSQArchiveIter *iter
+    );
 
 G_END_DECLS
 
-#endif /* __ARCHIVE_H__ */
+#endif /* __ARCHIVE_ITER_POOL_H__ */
diff --git a/libsqueeze/archive-iter.c b/libsqueeze/archive-iter.c
index 4b6c3a1..3fc35a8 100644
--- a/libsqueeze/archive-iter.c
+++ b/libsqueeze/archive-iter.c
@@ -47,80 +47,84 @@ guint buffer_flush_size = LSQ_ENTRY_CHILD_BUFFER_SIZE;
  *************************/
 
 static void
-lsq_archive_entry_props_free(const LSQArchive *archive, LSQArchiveEntry *entry);
+lsq_archive_entry_props_free ( const LSQArchive *archive, LSQArchiveEntry *entry );
 static void
-lsq_archive_entry_free(const LSQArchive *, LSQArchiveEntry *);
+lsq_archive_entry_free ( const LSQArchive *, LSQArchiveEntry * );
 static void
-lsq_archive_entry_save_free(const LSQArchive *, LSQArchiveEntry *);
+lsq_archive_entry_save_free ( const LSQArchive *, LSQArchiveEntry * );
 
 inline static const gchar *
-lsq_archive_entry_get_filename(const LSQArchiveEntry *);
+lsq_archive_entry_get_filename ( const LSQArchiveEntry * );
 inline static const gchar *
-lsq_archive_entry_get_contenttype(const LSQArchiveEntry *);
+lsq_archive_entry_get_contenttype ( const LSQArchiveEntry * );
 
 inline static guint
-lsq_archive_entry_n_children(const LSQArchiveEntry *);
-inline static LSQArchiveEntry*
-lsq_archive_entry_nth_child(const LSQArchiveEntry *, guint);
+lsq_archive_entry_n_children ( const LSQArchiveEntry * );
+inline static LSQArchiveEntry *
+lsq_archive_entry_nth_child ( const LSQArchiveEntry *, guint );
 inline static void
-lsq_archive_entry_flush_buffer(LSQArchiveEntry *);
+lsq_archive_entry_flush_buffer ( LSQArchiveEntry * );
 static LSQArchiveEntry *
-lsq_archive_entry_get_child(const LSQArchiveEntry *, const gchar *);
+lsq_archive_entry_get_child ( const LSQArchiveEntry *, const gchar * );
 static LSQArchiveEntry *
-lsq_archive_entry_add_child(LSQArchiveEntry *, const gchar *);
+lsq_archive_entry_add_child ( LSQArchiveEntry *, const gchar * );
 static gboolean
-lsq_archive_entry_remove_child(LSQArchiveEntry *entry, const gchar *filename);
+lsq_archive_entry_remove_child ( LSQArchiveEntry *entry, const gchar *filename );
 
-inline static const gchar*
-lsq_archive_entry_get_prop_str(const LSQArchive *, const LSQArchiveEntry *, guint);
+inline static const gchar *
+lsq_archive_entry_get_prop_str ( const LSQArchive *, const LSQArchiveEntry *, guint );
 inline static guint
-lsq_archive_entry_get_prop_uint(const LSQArchive *, const LSQArchiveEntry *, guint);
+lsq_archive_entry_get_prop_uint ( const LSQArchive *, const LSQArchiveEntry *, guint );
 inline static guint64
-lsq_archive_entry_get_prop_uint64(const LSQArchive *, const LSQArchiveEntry *, guint);
+lsq_archive_entry_get_prop_uint64 ( const LSQArchive *, const LSQArchiveEntry *, guint );
 inline static LSQDateTime
-lsq_archive_entry_get_prop_datetime(const LSQArchive *, const LSQArchiveEntry *, guint);
+lsq_archive_entry_get_prop_datetime ( const LSQArchive *, const LSQArchiveEntry *, guint );
 
 static void
-lsq_archive_entry_set_prop_str(const LSQArchive *, LSQArchiveEntry *, guint, gchar *);
+lsq_archive_entry_set_prop_str ( const LSQArchive *, LSQArchiveEntry *, guint, gchar * );
 static void
-lsq_archive_entry_set_prop_uint(const LSQArchive *, LSQArchiveEntry *, guint, guint);
+lsq_archive_entry_set_prop_uint ( const LSQArchive *, LSQArchiveEntry *, guint, guint );
 static void
-lsq_archive_entry_set_prop_uint64(const LSQArchive *, LSQArchiveEntry *, guint, guint64);
+lsq_archive_entry_set_prop_uint64 ( const LSQArchive *, LSQArchiveEntry *, guint, guint64 );
 static void
-lsq_archive_entry_set_prop_datetime(const LSQArchive *, LSQArchiveEntry *, guint, LSQDateTime);
+lsq_archive_entry_set_prop_datetime ( const LSQArchive *, LSQArchiveEntry *, guint, LSQDateTime );
 static void
-lsq_archive_entry_set_propsv(const LSQArchive *, LSQArchiveEntry *, gpointer *);
+lsq_archive_entry_set_propsv ( const LSQArchive *, LSQArchiveEntry *, gpointer * );
 static void
-lsq_archive_entry_set_propsva(const LSQArchive *, LSQArchiveEntry *, va_list);
+lsq_archive_entry_set_propsva ( const LSQArchive *, LSQArchiveEntry *, va_list );
 
 struct _LSQArchiveEntry
 {
-	gchar *filename;
-	gchar *content_type;
-	gpointer props;
-	LSQArchiveEntry **children;
-	LSQBTree *buffer;
-        guint buffer_length;
+    gchar *filename;
+    gchar *content_type;
+    gpointer props;
+    LSQArchiveEntry **children;
+    LSQBTree *buffer;
+    guint buffer_length; /* This field should only be available when it is valid, alloc it within the BTree for example. Maybe allocate the buffer pointer in the children array to save even more space */
 };
 
 
 /**************
  * Init stuff *
  **************/
-volatile LSQArchiveIterPool* pool;
+volatile LSQArchiveIterPool *pool;
 
 void
-lsq_archive_init_iter(LSQArchive *archive)
+lsq_archive_init_iter ( LSQArchive *archive )
 {
-	pool = archive->pool = lsq_archive_iter_pool_new();
-	archive->root_entry = g_new0(LSQArchiveEntry, 1);
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+
+    pool = archive->pool = lsq_archive_iter_pool_new();
+    archive->root_entry = g_new0( LSQArchiveEntry, 1 );
 }
 
 void
-lsq_archive_free_iter(LSQArchive *archive)
+lsq_archive_free_iter ( LSQArchive *archive )
 {
-	lsq_archive_iter_pool_free(archive->pool);
-	lsq_archive_entry_free(archive, archive->root_entry);
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+
+    lsq_archive_iter_pool_free( archive->pool );
+    lsq_archive_entry_free( archive, archive->root_entry );
 }
 
 /************************
@@ -128,816 +132,911 @@ lsq_archive_free_iter(LSQArchive *archive)
  ************************/
 
 static LSQArchiveIter *
-lsq_archive_iter_new(LSQArchiveEntry *entry, LSQArchiveIter *parent, LSQArchive *archive)
+lsq_archive_iter_new ( LSQArchiveEntry *entry, LSQArchiveIter *parent, LSQArchive *archive )
 {
-	/* create a new iter */
-	LSQArchiveIter *iter;
+    /* create a new iter */
+    LSQArchiveIter *iter;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != entry, NULL );
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+#endif
+
 #ifdef USE_LSQITER_SLICES
-	/* Lets see if there is an iter we can use */
-	if(lsq_archive_iter_pool_get_size(archive->pool) >= lsq_archive_iter_pool_get_reserved(archive->pool) || 
-	   !(iter = lsq_archive_iter_pool_get_iter(archive->pool, lsq_archive_iter_pool_get_size(archive->pool))))
-	{
-		/* No iter found, make a new one */
+    /* Lets see if there is an iter we can use */
+    if ( lsq_archive_iter_pool_get_size( archive->pool ) >= lsq_archive_iter_pool_get_reserved( archive->pool ) || 
+        !( iter = lsq_archive_iter_pool_get_iter( archive->pool, lsq_archive_iter_pool_get_size( archive->pool ) ) ) )
+    {
+        /* No iter found, make a new one */
 #ifdef USE_GSLICES
-			iter = g_slice_new(LSQArchiveIter);
+        iter = g_slice_new( LSQArchiveIter );
 #else
-			iter = g_new(LSQArchiveIter, 1);
+        iter = g_new( LSQArchiveIter, 1 );
 #endif
-	}
+    }
 #elif defined(USE_GSLICES)
-	iter = g_slice_new(LSQArchiveIter);
+    iter = g_slice_new( LSQArchiveIter );
 #else
-	iter = g_new(LSQArchiveIter, 1);
+    iter = g_new( LSQArchiveIter, 1 );
 #endif
-	iter->archive = archive;
-	iter->entry = entry;
-	iter->parent = parent?lsq_archive_iter_ref(parent):NULL;
-	iter->ref_count = 1;
+    iter->archive = archive;
+    iter->entry = entry;
+    iter->parent = parent ? lsq_archive_iter_ref( parent ) : NULL;
+    iter->ref_count = 1;
 
-	return iter;
+    return iter;
 }
 
 static LSQArchiveIter *
-lsq_archive_iter_get_for_path(LSQArchive *archive, GSList *path)
+lsq_archive_iter_get_for_path ( LSQArchive *archive, GSList *path )
 {
-	LSQArchiveIter *iter;
-	guint pos;
+    LSQArchiveIter *iter;
+    guint pos;
 
-	if ( NULL == path )
-		return NULL;
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+#endif
 
-	/* iter has been found */
-	if (TRUE == lsq_archive_iter_pool_find_iter(archive->pool, path->data, &iter, &pos))
-	{
-		return lsq_archive_iter_ref(iter);
-	}
+    if ( NULL == path )
+        return NULL;
 
-	/* create a new iter */
-	iter = lsq_archive_iter_new(path->data, NULL, archive);
+    /* iter has been found */
+    if ( TRUE == lsq_archive_iter_pool_find_iter( archive->pool, path->data, &iter, &pos ) )
+    {
+        return lsq_archive_iter_ref( iter );
+    }
 
-	lsq_archive_iter_pool_insert_iter(archive->pool, iter, pos);
+    /* create a new iter */
+    iter = lsq_archive_iter_new( path->data, NULL, archive );
 
-	/* must be done here, otherwise the pool gets currupted */
-	iter->parent = lsq_archive_iter_get_for_path(archive, path->next);
+    lsq_archive_iter_pool_insert_iter( archive->pool, iter, pos );
 
-	return iter;
+    /* must be done here, otherwise the pool gets currupted */
+    iter->parent = lsq_archive_iter_get_for_path( archive, path->next );
+
+    return iter;
 }
 
 static LSQArchiveIter *
-lsq_archive_iter_get_with_archive(LSQArchiveEntry *entry, LSQArchiveIter *parent, LSQArchive *archive)
+lsq_archive_iter_get_with_archive ( LSQArchiveEntry *entry, LSQArchiveIter *parent, LSQArchive *archive )
 {
-	LSQArchiveIter *iter;
-	guint pos;
+    LSQArchiveIter *iter;
+    guint pos;
 
 #ifdef DEBUG
-	g_return_val_if_fail(entry, NULL);
+    g_return_val_if_fail( NULL != entry, NULL );
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
 #endif
 
-	/* iter has been found */
-	if ( TRUE == lsq_archive_iter_pool_find_iter(archive->pool, entry, &iter, &pos) )
-	{
-		return lsq_archive_iter_ref(iter);
-	}
+    /* iter has been found */
+    if ( TRUE == lsq_archive_iter_pool_find_iter( archive->pool, entry, &iter, &pos ) )
+    {
+        return lsq_archive_iter_ref( iter );
+    }
 
 #ifdef DEBUG
-	if ( NULL != parent )
-	{
-		g_return_val_if_fail ( parent->archive == archive, NULL );
-	}
+    if ( NULL != parent )
+    {
+        g_return_val_if_fail( parent->archive == archive, NULL );
+    }
 #endif
 
-	/* create a new iter */
-	iter = lsq_archive_iter_new(entry, parent, archive);
+    /* create a new iter */
+    iter = lsq_archive_iter_new( entry, parent, archive );
 
-	lsq_archive_iter_pool_insert_iter(archive->pool, iter, pos);
+    lsq_archive_iter_pool_insert_iter( archive->pool, iter, pos );
 
-	return iter;
+    return iter;
 }
 
 static LSQArchiveIter *
-lsq_archive_iter_get_with_parent(LSQArchiveEntry *entry, LSQArchiveIter *parent)
+lsq_archive_iter_get_with_parent ( LSQArchiveEntry *entry, LSQArchiveIter *parent )
 {
-	LSQArchiveIter *iter;
-	guint pos;
+    LSQArchiveIter *iter;
+    guint pos;
 
 #ifdef DEBUG
-	g_return_val_if_fail(entry, NULL);
+    g_return_val_if_fail( NULL != entry, NULL );
+    g_return_val_if_fail( NULL != parent, NULL );
+#ifdef PADENTIC
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( parent->archive ), NULL );
 #endif
-
-	/* iter has been found */
-	if ( TRUE == lsq_archive_iter_pool_find_iter(parent->archive->pool, entry, &iter, &pos) )
-	{
-		return lsq_archive_iter_ref(iter);
-	}
-
-#ifdef DEBUG
-	g_return_val_if_fail(parent, NULL);
 #endif
 
-	/* create a new iter */
-	iter = lsq_archive_iter_new(entry, parent, parent->archive);
+    /* iter has been found */
+    if ( TRUE == lsq_archive_iter_pool_find_iter( parent->archive->pool, entry, &iter, &pos ) )
+    {
+        return lsq_archive_iter_ref( iter );
+    }
+
+    /* create a new iter */
+    iter = lsq_archive_iter_new( entry, parent, parent->archive );
 
-	lsq_archive_iter_pool_insert_iter(parent->archive->pool, iter, pos);
+    lsq_archive_iter_pool_insert_iter( parent->archive->pool, iter, pos );
 
-	return iter;
+    return iter;
 }
 
 static void
-lsq_archive_iter_free(LSQArchiveIter *iter)
+lsq_archive_iter_free ( LSQArchiveIter *iter )
 {
 #ifdef DEBUG
-	g_return_if_fail(iter);
+    g_return_if_fail( NULL != iter );
+#ifdef PADENTIC
+    g_return_if_fail( LSQ_IS_ARCHIVE( parent->archive ) );
 #endif
+#endif
+
+    lsq_archive_iter_pool_remove_iter( iter->archive->pool, iter);
 
-	lsq_archive_iter_pool_remove_iter(iter->archive->pool, iter);
+    /* free the entry if it doesn't exist */
+    if ( FALSE == lsq_archive_iter_is_real( iter ) )
+    {
+        lsq_archive_entry_free( iter->archive, iter->entry );
+    }
 
-	/* free the entry if it doesn't exist */
-	if ( FALSE == lsq_archive_iter_is_real(iter) )
-	{
-		lsq_archive_entry_free(iter->archive, iter->entry);
-	}
+    /* free the iter */
+    if ( NULL != iter->parent )
+    {
+        lsq_archive_iter_unref( iter->parent );
+    }
 
-	/* free the iter */
-	if ( NULL != iter->parent )
-	{
-		lsq_archive_iter_unref(iter->parent);
-	}
 #ifdef USE_LSQITER_SLICES
-	/* We don't free the poiter we moved it */
+    /* We don't free the poiter we moved it */
 #elif defined(USE_GSLICES)
-	g_slice_free(LSQArchiveIter, iter);
+    g_slice_free( LSQArchiveIter, iter );
 #else
-	g_free(iter);
+    g_free( iter );
 #endif
 }
 
 #ifdef DEBUG
 void
-_lsq_archive_iter_unref(LSQArchiveIter* iter, const gchar *file, int line)
+_lsq_archive_iter_unref ( LSQArchiveIter *iter, const gchar *loc )
 {
-	if ( ( NULL == iter ) || ( 0 == iter->ref_count ) )
-	{
-		g_debug("unref: %p file: %s line: %d", iter, file, line);
-	}
-
-	g_return_if_fail(iter);
-	g_return_if_fail(iter->ref_count);
-	
-	iter->ref_count--;
-
-	/* free the iter if there are no ref's left */
-	if ( 0 == iter->ref_count )
-	{
-		lsq_archive_iter_free(iter);
-	}
+    if ( ( NULL == iter ) || ( 0 == iter->ref_count ) )
+    {
+        g_debug( "unref: %p %s", iter, loc );
+    }
+
+    g_return_if_fail( NULL != iter );
+    g_return_if_fail( 0 != iter->ref_count );
+
+    --iter->ref_count;
+
+    /* free the iter if there are no ref's left */
+    if ( 0 == iter->ref_count )
+    {
+        lsq_archive_iter_free( iter );
+    }
 }
 #endif
 
 void
-lsq_archive_iter_unref(LSQArchiveIter* iter)
+lsq_archive_iter_unref ( LSQArchiveIter *iter )
 {
 #ifdef DEBUG
-	g_return_if_fail(iter);
+    g_return_if_fail( NULL != iter);
+    g_return_if_fail( 0 != iter->ref_count );
 #endif
-	g_return_if_fail(iter->ref_count);
-	
-	iter->ref_count--;
 
-	/* free the iter if there are no ref's left */
-	if ( 0 == iter->ref_count )
-	{
-		lsq_archive_iter_free(iter);
-	}
+    --iter->ref_count;
+
+    /* free the iter if there are no ref's left */
+    if ( 0 == iter->ref_count )
+    {
+        lsq_archive_iter_free( iter );
+    }
 }
 
 #ifdef DEBUG
 LSQArchiveIter *
-_lsq_archive_iter_ref(LSQArchiveIter* iter, const gchar *file, int line)
+_lsq_archive_iter_ref ( LSQArchiveIter *iter, const gchar *loc )
 {
-	if ( ( NULL == iter ) || ( 0 == iter->ref_count ) )
-	{
-		g_debug("ref: %p file: %s line: %d", iter, file, line);
-	}
+    if ( ( NULL == iter ) || ( 0 == iter->ref_count ) )
+    {
+        g_debug( "ref: %p %s", iter, loc );
+    }
 
-	g_return_val_if_fail(iter, NULL);
-	g_return_val_if_fail(iter->ref_count, NULL);
+    g_return_val_if_fail( NULL != iter, NULL );
+    g_return_val_if_fail( 0 != iter->ref_count, NULL );
 
-	iter->ref_count++;
+    ++iter->ref_count;
 
-	return iter;
+    return iter;
 }
 #endif
 
 LSQArchiveIter *
-lsq_archive_iter_ref(LSQArchiveIter* iter)
+lsq_archive_iter_ref ( LSQArchiveIter *iter )
 {
 #ifdef DEBUG
-	g_return_val_if_fail(iter, iter);
+    g_return_val_if_fail( NULL != iter, NULL );
+    g_return_val_if_fail( 0 != iter->ref_count, NULL );
 #endif
-	g_return_val_if_fail(iter->ref_count, NULL);
 
-	iter->ref_count++;
+    ++iter->ref_count;
 
-	return iter;
+    return iter;
 }
 
 gboolean
-lsq_archive_iter_is_real(const LSQArchiveIter *iter)
+lsq_archive_iter_is_real ( const LSQArchiveIter *iter )
 {
-	const LSQArchiveIter *parent;
-#ifdef DEBUG
-	g_return_val_if_fail(iter, FALSE);
-#endif
-	/* reverse the parent list */
-	parent = iter->parent;
-	if ( G_UNLIKELY ( NULL == parent ) )
-	{
-		/* the root entry is archive root entry */
-		if ( G_UNLIKELY ( iter->entry != iter->archive->root_entry ) )
-		{
-			return FALSE;
-		}
-	}
-	else
-	{
-		/* find the childeren */
-		if ( G_UNLIKELY ( 
-				iter->entry != lsq_archive_entry_get_child ( 
-						parent->entry,
-						lsq_archive_entry_get_filename(iter->entry) ) 
-				) 
-		)
-		{
-			return FALSE;
-		}
-	}
-	return TRUE;
+    const LSQArchiveIter *parent;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != iter, FALSE);
+#ifdef PADENTIC
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( parent->archive ), FALSE );
+#endif
+#endif
+
+    /* reverse the parent list */
+    parent = iter->parent;
+    if ( G_UNLIKELY ( NULL == parent ) )
+    {
+        /* the root entry is archive root entry */
+        if ( G_UNLIKELY ( iter->entry != iter->archive->root_entry ) )
+        {
+            return FALSE;
+        }
+    }
+    else
+    {
+        /* find the childeren */
+        if ( G_UNLIKELY ( 
+                iter->entry != lsq_archive_entry_get_child( 
+                    parent->entry,
+                    lsq_archive_entry_get_filename( iter->entry )
+                ) 
+            ) )
+        {
+            return FALSE;
+        }
+    }
+    return TRUE;
 }
 
 LSQArchiveIter *
-lsq_archive_iter_get_real_parent(LSQArchiveIter *iter)
+lsq_archive_iter_get_real_parent ( LSQArchiveIter *iter )
 {
-	GSList *back_stack = NULL;
-	GSList *back_iter;
-	LSQArchiveIter *parent;
-	LSQArchiveEntry *entry;
-	GSList *list;
-#ifdef DEBUG
-	g_return_val_if_fail(iter, NULL);
-#endif
-	/* reverse the parent list */
-	parent = iter;
-	while ( NULL != parent )
-	{
-		back_stack = g_slist_prepend(back_stack, parent);
-		parent = parent->parent;
-	}
-	/* the root entry is not archive root entry */
-	if ( ((LSQArchiveIter*)back_stack->data)->entry != iter->archive->root_entry )
-	{
-		/* TODO: Should do iter recovery here too? */
-		g_slist_free(back_stack);
-		return lsq_archive_iter_get_with_archive(iter->archive->root_entry, NULL, iter->archive);
-	}
-	list = g_slist_prepend(NULL, entry = iter->archive->root_entry);
-	/* find the childeren */
-	for(back_iter = g_slist_next(back_stack); NULL != back_iter; back_iter = g_slist_next(back_iter))
-	{
-		if(!(entry = lsq_archive_entry_get_child(entry, lsq_archive_entry_get_filename(((LSQArchiveIter*)back_iter->data)->entry))))
-			break;
-		list = g_slist_prepend(list, entry);
-	}
-	g_slist_free(back_stack);
-	iter = lsq_archive_iter_get_for_path(iter->archive, list);
-	g_slist_free(list);
-	return iter;
+    GSList *back_stack = NULL;
+    GSList *back_iter;
+    LSQArchiveIter *parent;
+    LSQArchiveEntry *entry;
+    GSList *list;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != iter, NULL );
+#ifdef PADENTIC
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( iter->archive ), NULL );
+#endif
+#endif
+
+    /* reverse the parent list */
+    parent = iter;
+    while ( NULL != parent )
+    {
+        back_stack = g_slist_prepend( back_stack, parent );
+        parent = parent->parent;
+    }
+    /* the root entry is not archive root entry */
+    if ( ((LSQArchiveIter *)back_stack->data)->entry != iter->archive->root_entry )
+    {
+        /* TODO: Should do iter recovery here too? */
+        g_slist_free( back_stack );
+        return lsq_archive_iter_get_with_archive( iter->archive->root_entry, NULL, iter->archive );
+    }
+    entry = iter->archive->root_entry;
+    list = g_slist_prepend( NULL, entry );
+    /* find the childeren */
+    for ( back_iter = g_slist_next( back_stack ); NULL != back_iter; back_iter = g_slist_next( back_iter ) )
+    {
+        if ( !( entry = lsq_archive_entry_get_child( entry, lsq_archive_entry_get_filename( ((LSQArchiveIter *)back_iter->data)->entry ) ) ) )
+        {
+            break;
+        }
+        list = g_slist_prepend( list, entry );
+    }
+    g_slist_free( back_stack );
+    iter = lsq_archive_iter_get_for_path( iter->archive, list );
+    g_slist_free( list );
+    return iter;
 }
 
 gboolean
-lsq_archive_iter_is_directory(const LSQArchiveIter *iter)
+lsq_archive_iter_is_directory ( const LSQArchiveIter *iter )
 {
-	const gchar *contenttype;
-#ifdef debug
-	g_return_val_if_fail(iter, FALSE);
-#endif
-	contenttype = lsq_archive_entry_get_contenttype(iter->entry);
-	if ( NULL == contenttype )
-	{
-		return FALSE;
-	}
-	if ( 0 == strcmp ( contenttype, LSQ_MIME_DIRECTORY ) )
-	{
-		return TRUE;
-	}
-	return FALSE;
+    const gchar *contenttype;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != iter, FALSE );
+#endif
+
+    contenttype = lsq_archive_entry_get_contenttype( iter->entry );
+    if ( NULL == contenttype )
+    {
+        return FALSE;
+    }
+    if ( 0 == strcmp ( contenttype, LSQ_MIME_DIRECTORY ) )
+    {
+        return TRUE;
+    }
+    return FALSE;
 }
 
 gboolean
-lsq_archive_iter_has_parent(const LSQArchiveIter *iter)
+lsq_archive_iter_has_parent ( const LSQArchiveIter *iter )
 {
-	return iter->parent?TRUE:FALSE;
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != iter, FALSE );
+#endif
+    return NULL != iter->parent;
 }
 
 LSQArchiveIter *
-lsq_archive_iter_get_parent(LSQArchiveIter *iter)
+lsq_archive_iter_get_parent ( LSQArchiveIter *iter )
 {
 #ifdef DEBUG
-	g_return_val_if_fail(iter, NULL);
+    g_return_val_if_fail( NULL != iter, NULL);
 #endif
-	return iter->parent?lsq_archive_iter_ref(iter->parent):NULL;
+    if ( NULL != iter->parent )
+    {
+        return lsq_archive_iter_ref( iter->parent );
+    }
+    return NULL;
 }
 
 guint
-lsq_archive_iter_n_children(const LSQArchiveIter *iter)
+lsq_archive_iter_n_children ( const LSQArchiveIter *iter )
 {
 #ifdef DEBUG
-	g_return_val_if_fail(iter, 0);
+    g_return_val_if_fail( NULL != iter, 0 );
 #endif
-	return lsq_archive_entry_n_children(iter->entry);
+    return lsq_archive_entry_n_children( iter->entry );
 }
 
 LSQArchiveIter *
-lsq_archive_iter_nth_child(LSQArchiveIter *parent, guint n)
+lsq_archive_iter_nth_child ( LSQArchiveIter *parent, guint n )
 {
-	LSQArchiveEntry *entry;
-	LSQArchiveIter *iter;
+    LSQArchiveEntry *entry;
+    LSQArchiveIter *iter;
+
 #ifdef DEBUG
-	g_return_val_if_fail(parent, NULL);
+    g_return_val_if_fail( NULL != parent, NULL );
 #endif
-	if ( n >= lsq_archive_entry_n_children(parent->entry) )
-	{
-		return NULL;
-	}
 
-	lsq_archive_entry_flush_buffer(parent->entry);
-	entry = lsq_archive_entry_nth_child(parent->entry, n);
-	iter = lsq_archive_iter_get_with_parent(entry, parent);
-	return iter;
+    if ( lsq_archive_entry_n_children( parent->entry ) <= n )
+    {
+        return NULL;
+    }
+
+    lsq_archive_entry_flush_buffer( parent->entry );
+    entry = lsq_archive_entry_nth_child( parent->entry, n );
+    iter = lsq_archive_iter_get_with_parent( entry, parent );
+    return iter;
 }
 
 LSQArchiveIter *
-lsq_archive_iter_get_child(LSQArchiveIter *parent, const gchar *filename)
+lsq_archive_iter_get_child ( LSQArchiveIter *parent, const gchar *filename )
 {
-	LSQArchiveEntry *entry;
-	LSQArchiveIter *iter;
+    LSQArchiveEntry *entry;
+    LSQArchiveIter *iter;
+
 #ifdef DEBUG
-	g_return_val_if_fail(parent, NULL);
-	g_return_val_if_fail(filename, NULL);
+    g_return_val_if_fail( NULL != parent, NULL );
+    g_return_val_if_fail( NULL != filename, NULL );
 #endif
-	entry = lsq_archive_entry_get_child(parent->entry, filename);
-	iter = lsq_archive_iter_get_with_parent(entry, parent);
-	return iter;
+
+    entry = lsq_archive_entry_get_child( parent->entry, filename );
+    iter = lsq_archive_iter_get_with_parent( entry, parent );
+    return iter;
 }
 
 LSQArchiveIter *
-lsq_archive_iter_add_file(LSQArchiveIter *parent, const gchar *filename)
+lsq_archive_iter_add_file ( LSQArchiveIter *parent, const gchar *filename )
 {
-	LSQArchiveEntry *entry;
-	LSQArchiveIter *iter;
-#ifdef DEBUG
-	g_return_val_if_fail(parent, NULL);
-	g_return_val_if_fail(filename, NULL);
-#endif
-	entry = lsq_archive_entry_get_child(parent->entry, filename);
-	if ( NULL == entry )
-	{
-		entry = lsq_archive_entry_add_child(parent->entry, filename);
-	}
-	iter = lsq_archive_iter_get_with_parent(entry, parent);
-	return iter;
+    LSQArchiveEntry *entry;
+    LSQArchiveIter *iter;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != parent, NULL );
+    g_return_val_if_fail( NULL != filename, NULL );
+#endif
+
+    entry = lsq_archive_entry_get_child( parent->entry, filename );
+    if ( NULL == entry )
+    {
+        entry = lsq_archive_entry_add_child( parent->entry, filename );
+    }
+    iter = lsq_archive_iter_get_with_parent( entry, parent );
+    return iter;
 }
 
 void
-lsq_archive_iter_remove(LSQArchiveIter *iter, gboolean recursive)
+lsq_archive_iter_remove ( LSQArchiveIter *iter, gboolean recursive )
 {
-	LSQArchiveIter *prev_iter;
-#ifdef DEBUG
-	g_return_if_fail(iter);
-	/* don't remove root entry */
-	g_return_if_fail(iter->parent);
-#endif
-	prev_iter = iter;
-	iter = iter->parent;
-
-	if ( 0 == lsq_archive_entry_n_children(iter->entry) )
-	{
-		recursive = TRUE;
-	}
-
-	if ( TRUE == recursive )
-	{
-		gboolean result;
-		while ( NULL != iter->parent )
-		{
-			if ( ( NULL != iter->entry->props ) || ( 1 < lsq_archive_entry_n_children(iter->entry) ) )
-			{
-				break;
-			}
-
-			prev_iter = iter;
-			iter = iter->parent;
-		}
-
-		result = lsq_archive_entry_remove_child(iter->entry, lsq_archive_entry_get_filename(prev_iter->entry));
-		if ( ( TRUE == result ) && 
-			 ( FALSE == lsq_archive_iter_pool_find_iter(prev_iter->archive->pool, prev_iter->entry, NULL, NULL) ) )
-		{
-			lsq_archive_entry_free(prev_iter->archive, prev_iter->entry);
-		}
-		else
-		{
-			lsq_archive_entry_save_free(prev_iter->archive, prev_iter->entry);
-		}
-	}
-	else
-	{
-		lsq_archive_entry_props_free(iter->archive, iter->entry);
-	}
+    LSQArchiveIter *prev_iter;
+
+#ifdef DEBUG
+    g_return_if_fail( NULL != iter );
+    /* don't remove root entry */
+    g_return_if_fail( NULL != iter->parent );
+#endif
+    prev_iter = iter;
+    iter = iter->parent;
+
+    if ( 0 == lsq_archive_entry_n_children( iter->entry ) )
+    {
+        recursive = TRUE;
+    }
+
+    if ( TRUE == recursive )
+    {
+        gboolean result;
+        while ( NULL != iter->parent )
+        {
+            if ( ( NULL != iter->entry->props ) || ( 1 < lsq_archive_entry_n_children( iter->entry ) ) )
+            {
+                break;
+            }
+
+            prev_iter = iter;
+            iter = iter->parent;
+        }
+
+        result = lsq_archive_entry_remove_child( iter->entry, lsq_archive_entry_get_filename( prev_iter->entry ) );
+        if ( ( TRUE == result ) && 
+                ( FALSE == lsq_archive_iter_pool_find_iter( prev_iter->archive->pool, prev_iter->entry, NULL, NULL ) )
+            )
+        {
+            lsq_archive_entry_free( prev_iter->archive, prev_iter->entry );
+        }
+        else
+        {
+            lsq_archive_entry_save_free( prev_iter->archive, prev_iter->entry );
+        }
+    }
+    else
+    {
+        lsq_archive_entry_props_free( iter->archive, iter->entry );
+    }
 }
 
 guint
-lsq_archive_iter_get_depth(const LSQArchiveIter *iter)
+lsq_archive_iter_get_depth ( const LSQArchiveIter *iter )
 {
-	guint depth = 0;
+    guint depth = 0;
 
 #ifdef DEBUG
-	g_return_val_if_fail(iter, 0);
+    /* This function has no problem accepting a NULL iter. But it shouldn't get one */
+    g_return_val_if_fail( NULL != iter, 0 );
 #endif
 
-	while ( NULL != iter )
-	{
-		iter = iter->parent;
-		depth++;
-	}
-	return depth;
+    while ( NULL != iter )
+    {
+        iter = iter->parent;
+        ++depth;
+    }
+    return depth;
 }
 
-gchar*
-lsq_archive_iter_get_path(const LSQArchiveIter *iter)
+gchar *
+lsq_archive_iter_get_path ( const LSQArchiveIter *iter )
 {
-	const gchar **list;
-	gchar *path;
-	guint depth;
-
-#ifdef DEBUG
-	g_return_val_if_fail(iter, NULL);
-#endif
-
-	depth = lsq_archive_iter_get_depth(iter);
-	
-	if ( TRUE == lsq_archive_iter_is_directory(iter) )
-	{
-		list = g_new(const gchar*, depth+2);
-		list[depth] = "";
-		list[depth+1] = NULL;
-	}
-	else
-	{
-		list = g_new(const gchar*, depth+1);
-		list[depth] =	NULL;
-	}
-
-	while ( 0 < depth )
-	{
-		depth--;
-		list[depth] = lsq_archive_entry_get_filename(iter->entry);
-		iter = iter->parent;
-	}
-
-	if ( NULL != list[0] )
-	{
-		path = g_strjoinv("/", (gchar**)list);
-	}
-	else
-	{
-		path = g_strjoinv("/", (gchar **)&list[1]);
-	}
-	
-	g_free(list);
-
-	return path;
+    const gchar **list;
+    gchar *path;
+    guint depth;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != iter, NULL);
+#endif
+
+    depth = lsq_archive_iter_get_depth( iter );
+
+    if ( TRUE == lsq_archive_iter_is_directory( iter ) )
+    {
+        list = g_new( const gchar *, depth + 2 );
+        list[depth] = "";
+        list[depth+1] = NULL;
+    }
+    else
+    {
+        list = g_new( const gchar *, depth + 1 );
+        list[depth] =	NULL;
+    }
+
+    while ( 0 < depth )
+    {
+        --depth;
+        list[depth] = lsq_archive_entry_get_filename( iter->entry );
+        iter = iter->parent;
+    }
+
+    if ( NULL == list[0] )
+    {
+        path = g_strjoinv( "/", (gchar **)&list[1] );
+    }
+    else
+    {
+        path = g_strjoinv( "/", (gchar **)list );
+    }
+
+    g_free( list );
+
+    return path;
 }
 
-const gchar*
-lsq_archive_iter_get_filename(const LSQArchiveIter *iter)
+const gchar *
+lsq_archive_iter_get_filename ( const LSQArchiveIter *iter )
 {
 #ifdef DEBUG
-	g_return_val_if_fail(iter, NULL);
+    g_return_val_if_fail( NULL != iter, NULL );
 #endif
-	return lsq_archive_entry_get_filename(iter->entry);
+    return lsq_archive_entry_get_filename( iter->entry );
 }
 
-const gchar*
-lsq_archive_iter_get_contenttype(const LSQArchiveIter *iter)
+const gchar *
+lsq_archive_iter_get_contenttype ( const LSQArchiveIter *iter )
 {
 #ifdef DEBUG
-	g_return_val_if_fail(iter, FALSE);
+    g_return_val_if_fail( NULL != iter, FALSE );
 #endif
-	return lsq_archive_entry_get_contenttype(iter->entry);
+    return lsq_archive_entry_get_contenttype( iter->entry );
 }
 
 gboolean
-lsq_archive_iter_get_prop_value(const LSQArchiveIter *iter, guint n, GValue *value)
+lsq_archive_iter_get_prop_value ( const LSQArchiveIter *iter, guint n, GValue *value )
 {
+    GType type;
+
 #ifdef DEBUG
-	g_return_val_if_fail(iter, FALSE);
-	g_return_val_if_fail(n < lsq_archive_n_entry_properties(iter->archive), FALSE);
-#endif
-	if ( LSQ_ARCHIVE_PROP_USER <= n )
-	{
-		g_value_init(value, lsq_archive_get_entry_property_type(iter->archive, n));
-	}
-	else
-	{
-		g_value_init(value, G_TYPE_STRING);
-	}
-
-	switch(G_VALUE_TYPE(value))
-	{
-		case G_TYPE_STRING:
-			g_value_set_string(value, lsq_archive_entry_get_prop_str(iter->archive, iter->entry, n));
-			break;
-		case G_TYPE_UINT:
-			g_value_set_uint(value, lsq_archive_entry_get_prop_uint(iter->archive, iter->entry, n));
-			break;
-		case G_TYPE_UINT64:
-			g_value_set_uint64(value, lsq_archive_entry_get_prop_uint64(iter->archive, iter->entry, n));
-			break;
-		default:
-			if ( LSQ_TYPE_DATETIME == G_VALUE_TYPE(value) )
-			{
-                            g_value_set_datetime(value, lsq_archive_entry_get_prop_datetime(iter->archive, iter->entry, n));
-                            break;
-			}
-			return FALSE;
-	}
-
-	return TRUE;
+    g_return_val_if_fail( NULL != iter, FALSE );
+#ifdef PADENTIC
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( iter->archive ), FALSE );
+#endif
+    g_return_val_if_fail( lsq_archive_n_entry_properties( iter->archive ) > n, FALSE );
+    g_return_val_if_fail( NULL != value, FALSE );
+#endif
+
+    type = G_TYPE_STRING;
+    if ( LSQ_ARCHIVE_PROP_USER <= n )
+    {
+        type = lsq_archive_get_entry_property_type( iter->archive, n );
+    }
+    g_value_init( value, type );
+
+    switch ( type )
+    {
+        case G_TYPE_STRING:
+            g_value_set_string( value, lsq_archive_entry_get_prop_str( iter->archive, iter->entry, n ) );
+            break;
+
+        case G_TYPE_UINT:
+            g_value_set_uint( value, lsq_archive_entry_get_prop_uint( iter->archive, iter->entry, n ) );
+            break;
+
+        case G_TYPE_UINT64:
+            g_value_set_uint64( value, lsq_archive_entry_get_prop_uint64( iter->archive, iter->entry, n ) );
+            break;
+
+        default:
+            if ( LSQ_TYPE_DATETIME == type )
+            {
+                g_value_set_datetime( value, lsq_archive_entry_get_prop_datetime( iter->archive, iter->entry, n ) );
+                break;
+            }
+#ifdef DEBUG
+            g_warn_if_reached();
+#endif
+            return FALSE;
+    }
+
+    return TRUE;
 }
 
 void
-lsq_archive_iter_set_prop_value(LSQArchiveIter *iter, guint n, const GValue *value)
+lsq_archive_iter_set_prop_value ( LSQArchiveIter *iter, guint n, const GValue *value )
 {
+    GType type;
+
+#ifdef DEBUG
+    g_return_if_fail( NULL != iter );
+#ifdef PADENTIC
+    g_return_if_fail( LSQ_IS_ARCHIVE( iter->archive ) );
+#endif
+    g_return_if_fail( LSQ_ARCHIVE_PROP_USER <= n );
+    g_return_if_fail( lsq_archive_n_entry_properties( iter->archive) > n );
+    g_return_if_fail( NULL != value );
+    g_return_if_fail( G_TYPE_CHECK_VALUE_TYPE( value, lsq_archive_get_entry_property_type( iter->archive, n ) ) );
+#endif
+
+    type = G_VALUE_TYPE( value );
+    switch ( type )
+    {
+        case G_TYPE_STRING:
+            lsq_archive_entry_set_prop_str( iter->archive, iter->entry, n, g_value_dup_string( value ) );
+            break;
+
+        case G_TYPE_UINT:
+            lsq_archive_entry_set_prop_uint( iter->archive, iter->entry, n, g_value_get_uint( value ) );
+            break;
+
+        case G_TYPE_UINT64:
+            lsq_archive_entry_set_prop_uint64( iter->archive, iter->entry, n, g_value_get_uint64( value ) );
+            break;
+
+        default:
+            if ( LSQ_TYPE_DATETIME == type )
+            {
+                lsq_archive_entry_set_prop_datetime( iter->archive, iter->entry, n, g_value_get_datetime( value ) );
+                break;
+            }
 #ifdef DEBUG
-	g_return_if_fail(iter);
-	g_return_if_fail(n >= LSQ_ARCHIVE_PROP_USER);
-	g_return_if_fail(n < lsq_archive_n_entry_properties(iter->archive));
-	g_return_if_fail(value);
-	g_return_if_fail(G_TYPE_CHECK_VALUE_TYPE(value, lsq_archive_get_entry_property_type(iter->archive, n)));
-#endif
-	switch(G_VALUE_TYPE(value))
-	{
-		case G_TYPE_STRING:
-			lsq_archive_entry_set_prop_str(iter->archive, iter->entry, n, g_value_dup_string(value));
-			break;
-		case G_TYPE_UINT:
-			lsq_archive_entry_set_prop_uint(iter->archive, iter->entry, n, g_value_get_uint(value));
-			break;
-		case G_TYPE_UINT64:
-			lsq_archive_entry_set_prop_uint64(iter->archive, iter->entry, n, g_value_get_uint64(value));
-			break;
-		default:
-			if ( LSQ_TYPE_DATETIME == G_VALUE_TYPE(value) )
-			{
-                            lsq_archive_entry_set_prop_datetime(iter->archive, iter->entry, n, g_value_get_datetime(value));
-                            break;
-                        }
-                        break;
-	}
+            g_warn_if_reached();
+#endif
+            break;
+    }
 }
 
 void
-lsq_archive_iter_set_prop(LSQArchiveIter *iter, guint n, gpointer value)
+lsq_archive_iter_set_prop ( LSQArchiveIter *iter, guint n, gpointer value )
 {
+    GType type;
+
 #ifdef DEBUG
-	g_return_if_fail(iter);
-	g_return_if_fail(n >= LSQ_ARCHIVE_PROP_USER);
-	g_return_if_fail(n < lsq_archive_n_entry_properties(iter->archive));
-	g_return_if_fail(value);
-#endif
-	switch(lsq_archive_get_entry_property_type(iter->archive, n))
-	{
-		case G_TYPE_STRING:
-			lsq_archive_entry_set_prop_str(iter->archive, iter->entry, n, value);
-			break;
-		case G_TYPE_UINT:
-			lsq_archive_entry_set_prop_uint(iter->archive, iter->entry, n, *(guint*)value);
-			break;
-		case G_TYPE_UINT64:
-			lsq_archive_entry_set_prop_uint64(iter->archive, iter->entry, n, *(guint64*)value);
-			break;
-		default:
-			if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type(iter->archive, n) )
-			{
-                            lsq_archive_entry_set_prop_datetime(iter->archive, iter->entry, n, *(LSQDateTime*)value);
-                            break;
-                        }
-                        break;
-	}
+    g_return_if_fail( NULL != iter );
+#ifdef PADENTIC
+    g_return_if_fail( LSQ_IS_ARCHIVE( iter->archive ) );
+#endif
+    g_return_if_fail( LSQ_ARCHIVE_PROP_USER <= n );
+    g_return_if_fail( lsq_archive_n_entry_properties( iter->archive) > n );
+    g_return_if_fail( NULL != value );
+#endif
+
+    type = lsq_archive_get_entry_property_type( iter->archive, n );
+    switch ( type )
+    {
+        case G_TYPE_STRING:
+            lsq_archive_entry_set_prop_str( iter->archive, iter->entry, n, value );
+            break;
+
+        case G_TYPE_UINT:
+            lsq_archive_entry_set_prop_uint( iter->archive, iter->entry, n, *(guint *)value );
+            break;
+
+        case G_TYPE_UINT64:
+            lsq_archive_entry_set_prop_uint64( iter->archive, iter->entry, n, *(guint64 *)value );
+            break;
+
+        default:
+            if ( LSQ_TYPE_DATETIME == type )
+            {
+                lsq_archive_entry_set_prop_datetime( iter->archive, iter->entry, n, *(LSQDateTime *)value );
+                break;
+            }
+#ifdef DEBUG
+            g_warn_if_reached();
+#endif
+            break;
+    }
 }
 
 void
-lsq_archive_iter_set_props(LSQArchiveIter *iter, ...)
+lsq_archive_iter_set_props ( LSQArchiveIter *iter, ... )
 {
-	va_list ap;
+    va_list ap;
+
 #ifdef DEBUG
-	g_return_if_fail(iter);
+    g_return_if_fail( NULL != iter );
+#ifdef PADENTIC
+    g_return_if_fail( LSQ_IS_ARCHIVE( iter->archive ) );
 #endif
-	va_start(ap, iter);
-	lsq_archive_entry_set_propsva(iter->archive, iter->entry, ap);
-	va_end(ap);
+#endif
+
+    va_start( ap, iter );
+    lsq_archive_entry_set_propsva( iter->archive, iter->entry, ap );
+    va_end( ap );
 }
 
 void
-lsq_archive_iter_set_propsv(LSQArchiveIter *iter, gpointer *props)
+lsq_archive_iter_set_propsv ( LSQArchiveIter *iter, gpointer *props )
 {
 #ifdef DEBUG
-	g_return_if_fail(iter);
-	g_return_if_fail(props);
-	g_return_if_fail(props[lsq_archive_n_entry_properties(iter->archive) - LSQ_ARCHIVE_PROP_USER] == NULL);
+    g_return_if_fail( NULL != iter);
+#ifdef PADENTIC
+    g_return_if_fail( LSQ_IS_ARCHIVE( iter->archive ) );
+#endif
+    g_return_if_fail( NULL != props );
+    g_return_if_fail( NULL == props[lsq_archive_n_entry_properties( iter->archive ) - LSQ_ARCHIVE_PROP_USER] );
 #endif
-	lsq_archive_entry_set_propsv(iter->archive, iter->entry, props);
+    lsq_archive_entry_set_propsv( iter->archive, iter->entry, props );
 }
 
 LSQArchiveIter *
-lsq_archive_get_iter(LSQArchive *archive, const gchar *path)
+lsq_archive_get_iter ( LSQArchive *archive, const gchar *path )
 {
-	gchar **buf;
-	gchar **iter;
-	LSQArchiveEntry *entry;
-	GSList *list;
-	LSQArchiveIter *aiter;
-#ifdef debug
-	g_return_val_if_fail(archive, NULL);
-#endif
-	if ( NULL == path )
-	{
-		return lsq_archive_iter_get_with_archive(archive->root_entry, NULL, archive);
-	}
-
-	buf = g_strsplit_set(path, "/\n", -1);
-	iter = buf;
-	entry = archive->root_entry;
-	list = g_slist_prepend(NULL, entry);
-
-	/* ignore '/' if we have no '/' in archive */
-	if ( ( '/' == path[0] ) && ( NULL != lsq_archive_entry_get_child(archive->root_entry, "/") ) )
-	{
-		g_free(iter[0]);
-		iter[0] = strdup("/");
-	}
-
-	/* find entries and make list */
-	while ( NULL != *iter )
-	{
-		if ( 0 != (*iter)[0] )
-		{
-			entry = lsq_archive_entry_get_child(entry, *iter);
-			if ( NULL == entry )
-			{
-				g_strfreev(buf);
-				g_slist_free(list);
-				return NULL;
-			}
-			list = g_slist_prepend(list, entry);
-		}
-		iter++;
-	}
-
-	g_strfreev(buf);
-
-	aiter = lsq_archive_iter_get_for_path(archive, list);
-	g_slist_free(list);
-
-	return aiter;
+    gchar **buf;
+    gchar **iter;
+    LSQArchiveEntry *entry;
+    GSList *list;
+    LSQArchiveIter *aiter;
+
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+#endif
+
+    if ( NULL == path )
+    {
+        return lsq_archive_iter_get_with_archive( archive->root_entry, NULL, archive );
+    }
+
+    buf = g_strsplit_set( path, "/\n", -1 );
+    iter = buf;
+    entry = archive->root_entry;
+    list = g_slist_prepend( NULL, entry );
+
+    /* ignore '/' if we have no '/' in archive */
+    if ( ( '/' == path[0] ) && ( NULL != lsq_archive_entry_get_child( archive->root_entry, "/" ) ) )
+    {
+        g_free( iter[0] );
+        iter[0] = strdup( "/" );
+    }
+
+    /* find entries and make list */
+    while ( NULL != *iter )
+    {
+        if ( 0 != (*iter)[0] )
+        {
+            entry = lsq_archive_entry_get_child( entry, *iter );
+            if ( NULL == entry )
+            {
+                g_strfreev( buf );
+                g_slist_free( list );
+                return NULL;
+            }
+            list = g_slist_prepend( list, entry );
+        }
+        ++iter;
+    }
+
+    g_strfreev( buf );
+
+    aiter = lsq_archive_iter_get_for_path( archive, list );
+    g_slist_free( list );
+
+    return aiter;
 }
 
 LSQArchiveIter *
-lsq_archive_add_file(LSQArchive *archive, const gchar *path)
+lsq_archive_add_file ( LSQArchive *archive, const gchar *path )
 {
-	gchar **buf;
-	gchar **iter;
-	LSQArchiveEntry *parent;
-	LSQArchiveEntry *child;
-	gchar *basefname;
-	GSList *list;
-	LSQArchiveIter *aiter;
-#ifdef debug
-	g_return_val_if_fail(archive, NULL);
-#endif
-	if ( NULL == path )
-	{
-		return lsq_archive_iter_get_with_archive(archive->root_entry, NULL, archive);
-	}
-	
-	buf = g_strsplit_set(path, "/\n", -1);
-	iter = buf;
-	parent = archive->root_entry;
-	list = g_slist_prepend(NULL, parent);
-
-	while ( NULL != *iter )
-	{
-		basefname = g_strconcat(*iter, *(iter+1)?"/":NULL, NULL);
-
-		if ( '\0' != basefname[0] )
-		{
-			child = lsq_archive_entry_get_child(parent, basefname);
-
-			if ( NULL == child )
-			{
-				child = lsq_archive_entry_add_child(parent, basefname);
-			}
-
-			list = g_slist_prepend(list, child);
-
-			parent = child;
-		}
-
-		g_free(basefname);
-
-		iter++;
-	}
-
-	g_strfreev(buf);
-
-	aiter = lsq_archive_iter_get_for_path(archive, list);
-	g_slist_free(list);
-
-	return aiter;
+    gchar **buf;
+    gchar **iter;
+    LSQArchiveEntry *parent;
+    LSQArchiveEntry *child;
+    gchar *basefname;
+    GSList *list;
+    LSQArchiveIter *aiter;
+
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+#endif
+
+    if ( NULL == path )
+    {
+        return lsq_archive_iter_get_with_archive( archive->root_entry, NULL, archive );
+    }
+
+    buf = g_strsplit_set( path, "/\n", -1 );
+    iter = buf;
+    parent = archive->root_entry;
+    list = g_slist_prepend( NULL, parent );
+
+    while ( NULL != *iter )
+    {
+        basefname = g_strconcat( *iter, ( NULL != iter[1] ) ? "/" : NULL, NULL );
+
+        if ( '\0' != basefname[0] )
+        {
+            child = lsq_archive_entry_get_child( parent, basefname );
+
+            if ( NULL == child )
+            {
+                child = lsq_archive_entry_add_child( parent, basefname );
+            }
+
+            list = g_slist_prepend( list, child );
+
+            parent = child;
+        }
+
+        g_free( basefname );
+
+        ++iter;
+    }
+
+    g_strfreev( buf );
+
+    aiter = lsq_archive_iter_get_for_path( archive, list );
+    g_slist_free( list );
+
+    return aiter;
 }
 
 gboolean
-lsq_archive_remove_file(LSQArchive *archive, const gchar *path)
+lsq_archive_remove_file ( LSQArchive *archive, const gchar *path )
 {
-	gchar **buf;
-	gchar **iter;
-	LSQArchiveEntry *entry;
-	GSList *prev_iter, *stack_iter, *stack = NULL;
-	gboolean result;
-
-#ifdef DEBUG
-	g_return_val_if_fail(archive, FALSE);
-	g_return_val_if_fail(path, FALSE);
-#endif
-
-	buf = g_strsplit_set(path, "/\n", -1);
-	iter = buf;
-	entry = archive->root_entry;
-
-	if ( ( '/' == path[0] ) && ( NULL != lsq_archive_entry_get_child(archive->root_entry, "/") ) )
-	{
-		g_free(iter[0]);
-		iter[0] = strdup("/");
-	}
-
-	while ( NULL != *iter )
-	{
-		if ( 0 != (*iter)[0] )
-		{
-			entry = lsq_archive_entry_get_child(entry, *iter);
-			if ( NULL == entry )
-			{
-				g_slist_free(stack);
-				g_strfreev(buf);
-				return FALSE;
-			}
-			stack = g_slist_prepend(stack, entry);
-		}
-		iter++;
-	}
-
-	g_strfreev(buf);
-
-	stack_iter = g_slist_next(stack);
-	prev_iter = stack;
-
-	while ( NULL != stack_iter )
-	{
-		entry = (LSQArchiveEntry*)stack_iter->data;
-
-		if ( (NULL != entry->props ) || ( 1 < lsq_archive_entry_n_children(entry) ) )
-		{
-			break;
-		}
-
-		prev_iter = stack_iter;
-		stack_iter = g_slist_next(stack_iter);
-	}
-
-	if ( NULL == stack_iter )
-	{
-		entry = archive->root_entry;
-	}
-
-	result = lsq_archive_entry_remove_child(entry, lsq_archive_entry_get_filename((LSQArchiveEntry*)prev_iter->data));
-	if(result && !lsq_archive_iter_pool_find_iter(archive->pool, prev_iter->data, NULL, NULL))
-	{
-		lsq_archive_entry_free(archive, entry);
-	}
-
-	g_slist_free(stack);
-
-	return result;
+    gchar **buf;
+    gchar **iter;
+    LSQArchiveEntry *entry;
+    GSList *prev_iter, *stack_iter, *stack = NULL;
+    gboolean result;
+
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), FALSE );
+    g_return_val_if_fail( NULL != path, FALSE );
+#endif
+
+    buf = g_strsplit_set( path, "/\n", -1 );
+    iter = buf;
+    entry = archive->root_entry;
+
+    if ( ( '/' == path[0] ) && ( NULL != lsq_archive_entry_get_child( archive->root_entry, "/" ) ) )
+    {
+        g_free( iter[0] );
+        iter[0] = strdup( "/" );
+    }
+
+    while ( NULL != *iter )
+    {
+        if ( 0 != (*iter)[0] )
+        {
+            entry = lsq_archive_entry_get_child( entry, *iter );
+            if ( NULL == entry )
+            {
+                g_slist_free( stack );
+                g_strfreev( buf );
+                return FALSE;
+            }
+            stack = g_slist_prepend( stack, entry );
+        }
+        ++iter;
+    }
+
+    g_strfreev( buf );
+
+    stack_iter = g_slist_next( stack );
+    prev_iter = stack;
+
+    while ( NULL != stack_iter )
+    {
+        entry = (LSQArchiveEntry *)stack_iter->data;
+
+        if ( ( NULL != entry->props ) || ( 1 < lsq_archive_entry_n_children( entry ) ) )
+        {
+            break;
+        }
+
+        prev_iter = stack_iter;
+        stack_iter = g_slist_next( stack_iter );
+    }
+
+    if ( NULL == stack_iter )
+    {
+        entry = archive->root_entry;
+    }
+
+    result = lsq_archive_entry_remove_child( entry, lsq_archive_entry_get_filename( (LSQArchiveEntry *)prev_iter->data ) );
+    if ( result && !lsq_archive_iter_pool_find_iter( archive->pool, prev_iter->data, NULL, NULL ) )
+    {
+        lsq_archive_entry_free( archive, entry );
+    }
+
+    g_slist_free( stack );
+
+    return result;
 }
 
 /*************************
@@ -945,664 +1044,877 @@ lsq_archive_remove_file(LSQArchive *archive, const gchar *path)
  *************************/
 
 static LSQArchiveEntry *
-lsq_archive_entry_new(const gchar *filename)
+lsq_archive_entry_new ( const gchar *filename )
 {
-	LSQArchiveEntry *entry = g_new0(LSQArchiveEntry, 1);
-
-	const gchar *pos = strchr(filename, '/');
-
-	if ( NULL != pos )
-	{
-		entry->filename = g_strndup(filename, (gsize)(pos - filename));
-		entry->content_type = g_strdup(LSQ_MIME_DIRECTORY);
-	}
-	else
-	{
-		entry->filename = g_strdup(filename);
-		if ( TRUE == g_utf8_validate (filename, -1, NULL) )
-		{
-			entry->content_type = g_content_type_guess(entry->filename, NULL, 0, NULL);
-		}
-		else
-		{
-			gchar *utf8_file = g_convert(filename, -1, "UTF-8", "WINDOWS-1252", NULL, NULL, NULL);
-			entry->content_type = g_content_type_guess(utf8_file, NULL, 0, NULL);
-			g_free(utf8_file);
-		}
-	}
-
-	return entry;
+    LSQArchiveEntry *entry;
+    const gchar *pos;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != filename, NULL );
+#endif
+
+    entry = g_new0( LSQArchiveEntry, 1 );
+
+    pos = strchr( filename, '/' );
+
+    if ( NULL != pos )
+    {
+        entry->filename = g_strndup( filename, (gsize)(pos - filename) );
+        entry->content_type = g_strdup( LSQ_MIME_DIRECTORY );
+    }
+    else
+    {
+        entry->filename = g_strdup( filename );
+        if ( TRUE == g_utf8_validate( filename, -1, NULL ) )
+        {
+            entry->content_type = g_content_type_guess( entry->filename, NULL, 0, NULL );
+        }
+        else
+        {
+            gchar *utf8_file = g_convert( filename, -1, "UTF-8", "WINDOWS-1252", NULL, NULL, NULL );
+            entry->content_type = g_content_type_guess( utf8_file, NULL, 0, NULL );
+            g_free( utf8_file );
+        }
+    }
+
+    return entry;
 }
 
 static void
-lsq_archive_entry_props_free(const LSQArchive *archive, LSQArchiveEntry *entry)
+lsq_archive_entry_props_free ( const LSQArchive *archive, LSQArchiveEntry *entry )
 {
-	guint i;
-	guint offset;
-	gpointer props_iter = entry->props;
-	/* free the properties */
-	if ( NULL != props_iter )
-	{
-		/* walk all properties */
-		for ( i=0 ; i < (lsq_archive_n_entry_properties(archive) - LSQ_ARCHIVE_PROP_USER) ; ++i )
-		{
-			switch ( lsq_archive_get_entry_property_type(archive, i+LSQ_ARCHIVE_PROP_USER) )
-			{
-				case G_TYPE_STRING:
-					/* free only strings */
-					offset = lsq_archive_get_entry_property_offset(archive, i+LSQ_ARCHIVE_PROP_USER);
-					g_free(((gchar **)props_iter)[offset]);
-					((gchar **)props_iter)[offset] = NULL;
-					break;
-			}
-		}
-		g_free(entry->props);
-		entry->props = NULL;
-	}
+    guint i;
+    guint offset;
+    gpointer props_iter;
+
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+    g_return_if_fail( NULL != entry );
+#endif
+
+    props_iter = entry->props;
+
+    /* free the properties */
+    if ( NULL != props_iter )
+    {
+        /* walk all properties */
+        for ( i = LSQ_ARCHIVE_PROP_USER; i < ( lsq_archive_n_entry_properties( archive ) ); ++i )
+        {
+            switch ( lsq_archive_get_entry_property_type( archive, i ) )
+            {
+                case G_TYPE_STRING:
+                    /* free only strings */
+                    offset = lsq_archive_get_entry_property_offset( archive, i );
+                    g_free( ((gchar **)props_iter)[offset] );
+                    ((gchar **)props_iter)[offset] = NULL;
+                    break;
+            }
+        }
+        g_free( entry->props );
+        entry->props = NULL;
+    }
 }
 
 static void
-lsq_archive_entry_save_free(const LSQArchive *archive, LSQArchiveEntry *entry)
+lsq_archive_entry_save_free ( const LSQArchive *archive, LSQArchiveEntry *entry )
 {
-	guint i = 0; 
-	LSQBTree *buffer_iter;
-
-	entry->buffer = lsq_btree_flatten(entry->buffer);
-	buffer_iter = entry->buffer;
-
-	/* free the buffer */
-	for ( ; NULL != buffer_iter ; buffer_iter = buffer_iter->next )
-	{
-		if(!lsq_archive_iter_pool_find_iter(archive->pool, buffer_iter->entry, NULL, NULL))
-			lsq_archive_entry_free(archive, buffer_iter->entry);
-		else
-			lsq_archive_entry_save_free(archive, buffer_iter->entry);
-	}
-	lsq_btree_free(entry->buffer);
-	entry->buffer = NULL;
-        entry->buffer_length = 0;
-
-	/* free the sorted list */
-	if ( NULL != entry->children )
-	{
-		/* first element of the array (*entry->children) contains the size of the array */
-		for ( i = 1 ; i <= GPOINTER_TO_UINT(*entry->children) ; ++i )
-		{
-			if(!lsq_archive_iter_pool_find_iter(archive->pool, entry->children[i], NULL, NULL))
-				lsq_archive_entry_free(archive, entry->children[i]);
-			else
-				lsq_archive_entry_save_free(archive, entry->children[i]);
-		}
-
-		g_free(entry->children);
-		entry->children = NULL;
-	}
-
-	/* free the properties */
-	lsq_archive_entry_props_free(archive, entry);
+    guint i = 0; 
+    LSQBTree *buffer_iter;
+
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+    g_return_if_fail( NULL != entry );
+#endif
+
+    entry->buffer = lsq_btree_flatten( entry->buffer );
+    buffer_iter = entry->buffer;
+
+    /* free the buffer */
+    for ( ; NULL != buffer_iter; buffer_iter = buffer_iter->next )
+    {
+        if ( FALSE == lsq_archive_iter_pool_find_iter( archive->pool, buffer_iter->entry, NULL, NULL ) )
+        {
+            lsq_archive_entry_free( archive, buffer_iter->entry );
+        }
+        else
+        {
+            lsq_archive_entry_save_free( archive, buffer_iter->entry );
+        }
+    }
+    lsq_btree_free( entry->buffer );
+    entry->buffer = NULL;
+    entry->buffer_length = 0;
+
+    /* free the sorted list */
+    if ( NULL != entry->children )
+    {
+        /* first element of the array (*entry->children) contains the size of the array */
+        for ( i = 1 ; i <= GPOINTER_TO_UINT( *entry->children ) ; ++i )
+        {
+            if ( FALSE == lsq_archive_iter_pool_find_iter( archive->pool, entry->children[i], NULL, NULL ) )
+            {
+                lsq_archive_entry_free( archive, entry->children[i] );
+            }
+            else
+            {
+                lsq_archive_entry_save_free( archive, entry->children[i] );
+            }
+        }
+
+        g_free( entry->children );
+        entry->children = NULL;
+    }
+
+    /* free the properties */
+    lsq_archive_entry_props_free( archive, entry );
 }
 
 static void
-lsq_archive_entry_free(const LSQArchive *archive, LSQArchiveEntry *entry)
+lsq_archive_entry_free ( const LSQArchive *archive, LSQArchiveEntry *entry )
 {
-	guint i = 0; 
-	LSQBTree *buffer_iter;
-
-	entry->buffer = lsq_btree_flatten(entry->buffer);
-	buffer_iter = entry->buffer;
-
-	/* free the buffer */
-	for ( ; NULL != buffer_iter; buffer_iter = buffer_iter->next )
-	{
-		lsq_archive_entry_free(archive, buffer_iter->entry);
-	}
-	lsq_btree_free(entry->buffer);
-	entry->buffer = NULL;
-        entry->buffer_length = 0;
-
-	/* free the sorted list */
-	if ( NULL != entry->children )
-	{
-		/* first element of the array (*entry->children) contains the size of the array */
-		for(i = 1; i <= GPOINTER_TO_UINT(*entry->children); ++i)
-			lsq_archive_entry_free(archive, entry->children[i]);
-
-		g_free(entry->children);
-		entry->children = NULL;
-	}
-
-	/* free the properties */
-	lsq_archive_entry_props_free(archive, entry);
-
-	/* free the content type */
-	if ( NULL != entry->content_type )
-	{
-		g_free (entry->content_type);
-		entry->content_type = NULL;
-	}
-
-	/* free the entry */
-	g_free(entry->filename);
-	g_free(entry);
+    guint i = 0; 
+    LSQBTree *buffer_iter;
+
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+    g_return_if_fail( NULL != entry );
+#endif
+
+    entry->buffer = lsq_btree_flatten( entry->buffer );
+    buffer_iter = entry->buffer;
+
+    /* free the buffer */
+    for ( ; NULL != buffer_iter; buffer_iter = buffer_iter->next )
+    {
+        lsq_archive_entry_free( archive, buffer_iter->entry );
+    }
+    lsq_btree_free( entry->buffer );
+    entry->buffer = NULL;
+    entry->buffer_length = 0;
+
+    /* free the sorted list */
+    if ( NULL != entry->children )
+    {
+        /* first element of the array (*entry->children) contains the size of the array */
+        for(i = 1; i <= GPOINTER_TO_UINT( *entry->children ); ++i)
+        {
+            lsq_archive_entry_free( archive, entry->children[i] );
+        }
+
+        g_free( entry->children );
+        entry->children = NULL;
+    }
+
+    /* free the properties */
+    lsq_archive_entry_props_free( archive, entry );
+
+    /* free the content type */
+    if ( NULL != entry->content_type )
+    {
+        g_free( entry->content_type );
+        entry->content_type = NULL;
+    }
+
+    /* free the entry */
+    g_free( entry->filename );
+    g_free( entry );
 }
 
 inline static const gchar *
-lsq_archive_entry_get_filename(const LSQArchiveEntry *entry)
+lsq_archive_entry_get_filename ( const LSQArchiveEntry *entry )
 {
-	return entry->filename;
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != entry, NULL );
+#endif
+    return entry->filename;
 }
 
 inline static const gchar *
-lsq_archive_entry_get_contenttype(const LSQArchiveEntry *entry)
+lsq_archive_entry_get_contenttype ( const LSQArchiveEntry *entry )
 {
-	return entry->content_type;
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != entry, NULL );
+#endif
+    return entry->content_type;
 }
 
 inline static guint
-lsq_archive_entry_n_children(const LSQArchiveEntry *entry)
+lsq_archive_entry_n_children ( const LSQArchiveEntry *entry )
 {
-	/* the first element of the array (*entry->children) contains the size of the array */
-	return ((entry->children?GPOINTER_TO_UINT(*entry->children):0) + lsq_btree_length(entry->buffer));
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != entry, 0 );
+#endif
+    /* the first element of the array (*entry->children) contains the size of the array */
+    return ( ( ( NULL != entry->children ) ? GPOINTER_TO_UINT( *entry->children ) : 0 ) + lsq_btree_length( entry->buffer ));
 }
 
-inline static LSQArchiveEntry*
-lsq_archive_entry_nth_child(const LSQArchiveEntry *entry, guint n)
+inline static LSQArchiveEntry *
+lsq_archive_entry_nth_child ( const LSQArchiveEntry *entry, guint n )
 {
-	/* the first element of the array (*entry->children) contains the size of the array */
-	return entry->children[n+1];
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != entry, NULL );
+    g_return_val_if_fail( NULL == entry->buffer, NULL );
+    g_return_val_if_fail( lsq_archive_entry_n_children( entry ) > n, NULL );
+#endif
+    /* the first element of the array (*entry->children) contains the size of the array */
+    return entry->children[n+1];
 }
 
 inline static void
-lsq_archive_entry_flush_buffer(LSQArchiveEntry *entry)
+lsq_archive_entry_flush_buffer ( LSQArchiveEntry *entry )
 {
-	guint max_children;
-	guint begin = 1;
-	guint pos = 0;
-	gint cmp = 1;
-	guint old_i = 1;
-	guint new_i = 1;
-	guint size;
-	guint n_children;
-	LSQBTree *buffer_iter = NULL;
-	LSQArchiveEntry **children_old;
-
-	if ( NULL == entry->buffer )
-	{
-		return;
-	}
-
-	//lsq_btree_print(entry->buffer);
-
-	/* Flatten the btree so we can iterate */
-	entry->buffer = lsq_btree_flatten(entry->buffer);
-
-	/* the first element of the array (*entry->children) contains the size of the array */
-	size = entry->children?GPOINTER_TO_UINT(*entry->children):0;
-	n_children = size;
-	children_old = (LSQArchiveEntry **)entry->children;
-
-	max_children = (n_children + lsq_btree_length(entry->buffer));
-	
-	/* do all elements of the buffer */
-	entry->children = g_new(LSQArchiveEntry *, max_children+1);
-	for ( buffer_iter = entry->buffer ; NULL != buffer_iter ; buffer_iter = buffer_iter->next )
-	{
-		size = n_children + 1 - begin;
-		/* binary search algoritme */
-		while ( 0 != size )
-		{
-			pos = (size / 2);
-
-			cmp = strcmp(buffer_iter->entry->filename, children_old[begin+pos]->filename);
-			if ( 0 == cmp )
-			{
-				break;
-			}
-
-			if ( 0 > cmp )
-			{
-				size = pos;
-			}
-			else
-			{
-				size -= ++pos;
-				begin += pos;
-			}
-		}
-		if ( 0 == cmp )
-		{
-			g_critical("THIS SHOULD NOT HAPPEN!!! (the universe has just collapsed)");
-		}
-		else
-		{
-			/* copy from old to new list */
-			while ( old_i < begin )
-			{
-				entry->children[new_i++] = children_old[old_i++];
-			}
-			entry->children[new_i++] = buffer_iter->entry;
-		}
-	}
-	/* copy tailing from old to new list */
-	while ( old_i <= n_children )
-	{
-		entry->children[new_i++] = children_old[old_i++];
-	}
-	n_children = new_i - 1;
-	/* the first element of the array (*entry->children) contains the size of the array */
-	*entry->children = GUINT_TO_POINTER(n_children);
-	
-	/* free the buffer */
-	lsq_btree_free(entry->buffer);
-	entry->buffer = NULL;
-        entry->buffer_length = 0;
-
-	g_free(children_old);
+    guint max_children;
+    guint begin = 1;
+    guint pos = 0;
+    gint cmp = 1;
+    guint old_i = 1;
+    guint new_i = 1;
+    guint size;
+    guint n_children;
+    LSQBTree *buffer_iter = NULL;
+    LSQArchiveEntry **children_old;
+
+#ifdef DEBUG
+    g_return_if_fail( NULL != entry );
+#endif
+
+    if ( NULL == entry->buffer )
+    {
+        return;
+    }
+
+    //lsq_btree_print(entry->buffer);
+
+    /* Flatten the btree so we can iterate */
+    entry->buffer = lsq_btree_flatten( entry->buffer );
+
+    /* the first element of the array (*entry->children) contains the size of the array */
+    size = ( NULL != entry->children) ? GPOINTER_TO_UINT( *entry->children ) : 0;
+    n_children = size;
+    children_old = (LSQArchiveEntry **)entry->children;
+
+    max_children = ( n_children + lsq_btree_length( entry->buffer ) );
+
+    /* do all elements of the buffer */
+    entry->children = g_new( LSQArchiveEntry *, max_children + 1 );
+    for ( buffer_iter = entry->buffer; NULL != buffer_iter; buffer_iter = buffer_iter->next )
+    {
+        size = n_children + 1 - begin;
+        /* binary search algoritme */
+        while ( 0 != size )
+        {
+            pos = ( size / 2 );
+
+            cmp = strcmp( buffer_iter->entry->filename, children_old[begin+pos]->filename );
+            if ( 0 == cmp )
+            {
+                break;
+            }
+
+            if ( 0 > cmp )
+            {
+                size = pos;
+            }
+            else
+            {
+                size -= ++pos;
+                begin += pos;
+            }
+        }
+        if ( 0 == cmp )
+        {
+            g_error( "THIS SHOULD NOT HAPPEN!!! (the universe has just collapsed)" );
+        }
+        else
+        {
+            /* copy from old to new list */
+            while ( old_i < begin )
+            {
+                entry->children[new_i++] = children_old[old_i++];
+            }
+            entry->children[new_i++] = buffer_iter->entry;
+        }
+    }
+    /* copy tailing from old to new list */
+    while ( old_i <= n_children )
+    {
+        entry->children[new_i++] = children_old[old_i++];
+    }
+    n_children = new_i - 1;
+    /* the first element of the array (*entry->children) contains the size of the array */
+    *entry->children = GUINT_TO_POINTER( n_children );
+
+    /* free the buffer */
+    lsq_btree_free( entry->buffer );
+    entry->buffer = NULL;
+    entry->buffer_length = 0;
+
+    g_free( children_old );
 }
 
 static LSQArchiveEntry *
-lsq_archive_entry_get_child(const LSQArchiveEntry *entry, const gchar *filename)
+lsq_archive_entry_get_child ( const LSQArchiveEntry *entry, const gchar *filename )
 {
-	LSQBTree *buffer_iter = NULL;
-	/* the first element of the array (*entry->children) contains the size of the array */
-	guint size = entry->children?GPOINTER_TO_UINT(*entry->children):0;
-	guint pos = 0;
-	guint begin = 1;
-	gint cmp = 0;
-	gchar *_filename = NULL;
-	const gchar *_pos = strchr(filename, '/');
-
-	/* remove trailing '/' */
-	if ( 0 != _pos )
-	{
-		_filename = g_strndup(filename, (gsize)(_pos - filename));
-		filename = _filename;
-	}
-
-	/* binary search algoritme */
-	while ( 0 != size )
-	{
-		pos = (size / 2);
-
-		cmp = strcmp(filename, entry->children[begin+pos]->filename);
-		if ( 0 == cmp )
-		{
-			g_free(_filename);
-			return entry->children[begin+pos];
-		}
-
-		if ( 0 > cmp )
-		{
-			size = pos;
-		}
-		else
-		{
-			size -= ++pos;
-			begin += pos;
-		}
-	}
-
-	/* search the buffer */
-	buffer_iter = entry->buffer;
-	while ( NULL != buffer_iter )
-	{
-		/* archive can be NULL */
-		cmp = strcmp(filename, buffer_iter->entry->filename);
-
-		if ( cmp < 0 )
-		{
-		    buffer_iter = buffer_iter->left;
-		}
-		else if ( cmp > 0 )
-		{
-		    buffer_iter = buffer_iter->right;
-		}
-		else
-		{
-		    g_free(_filename);
-		    return buffer_iter->entry;
-		}
-	}
-
-	g_free(_filename);
-	return NULL;
+    LSQBTree *buffer_iter = NULL;
+    guint size = 0;
+    guint pos = 0;
+    guint begin = 1;
+    gint cmp = 0;
+    gchar *_filename = NULL;
+    const gchar *_pos;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != entry, NULL );
+    g_return_val_if_fail( NULL != filename, NULL );
+#endif
+
+    if ( NULL != entry->children )
+    {
+        /* the first element of the array (*entry->children) contains the size of the array */
+        size = GPOINTER_TO_UINT( *entry->children );
+    }
+
+    _pos = strchr( filename, '/' );
+
+    /* remove trailing '/' */
+    if ( 0 != _pos )
+    {
+        _filename = g_strndup( filename, (gsize)(_pos - filename) );
+        filename = _filename;
+    }
+
+    /* binary search algoritme */
+    while ( 0 != size )
+    {
+        pos = ( size / 2 );
+
+        cmp = strcmp( filename, entry->children[begin+pos]->filename );
+        if ( 0 == cmp )
+        {
+            g_free( _filename );
+            return entry->children[begin+pos];
+        }
+
+        if ( 0 > cmp )
+        {
+            size = pos;
+        }
+        else
+        {
+            size -= ++pos;
+            begin += pos;
+        }
+    }
+
+    /* search the buffer */
+    buffer_iter = entry->buffer;
+    while ( NULL != buffer_iter )
+    {
+        /* archive can be NULL */
+        cmp = strcmp( filename, buffer_iter->entry->filename );
+
+        if ( cmp < 0 )
+        {
+            buffer_iter = buffer_iter->left;
+        }
+        else if ( cmp > 0 )
+        {
+            buffer_iter = buffer_iter->right;
+        }
+        else
+        {
+            g_free( _filename );
+            return buffer_iter->entry;
+        }
+    }
+
+    g_free( _filename );
+    return NULL;
 }
 
 static gint
-lsq_archive_entry_compare(LSQArchiveEntry *a, LSQArchiveEntry *b)
+lsq_archive_entry_compare ( LSQArchiveEntry *a, LSQArchiveEntry *b )
 {
-	return strcmp(a->filename, b->filename);
+    return strcmp( a->filename, b->filename );
 }
 
 static LSQArchiveEntry *
-lsq_archive_entry_add_child(LSQArchiveEntry *parent, const gchar *filename)
+lsq_archive_entry_add_child ( LSQArchiveEntry *parent, const gchar *filename )
 {
-	LSQArchiveEntry *child = lsq_archive_entry_new(filename);
-	const gchar *contenttype = lsq_archive_entry_get_contenttype(parent);
-
-	if ( ( NULL == contenttype ) || ( 0 != strcmp ( contenttype, LSQ_MIME_DIRECTORY ) ) )
-	{
-		/*
-		if(parent->content_type)
-			thunar_vfs_mime_info_unref(parent->mime_info);
-		parent->mime_info = thunar_vfs_mime_database_get_info(lsq_mime_database, LSQ_MIME_DIRECTORY);
-		*/
-	}
-
-	//g_debug("i: %s", filename);
-	parent->buffer = lsq_btree_insert_sorted_single(parent->buffer, child, (GCompareFunc)lsq_archive_entry_compare);
-
-	/* Cache the length so we doen't have to check every time */
-	parent->buffer_length++;
-
-	if ( LSQ_ENTRY_CHILD_BUFFER_SIZE == parent->buffer_length )
-	{
-		lsq_archive_entry_flush_buffer(parent);
-	}
-	
-	return child;
+    LSQArchiveEntry *child;
+    gchar *contenttype;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != parent, NULL );
+    g_return_val_if_fail( NULL != filename, NULL );
+#endif
+
+    child = lsq_archive_entry_new( filename );
+    contenttype = parent->content_type;
+
+    if ( ( NULL == contenttype ) || ( 0 != strcmp( contenttype, LSQ_MIME_DIRECTORY ) ) )
+    {
+        g_free( contenttype );
+        parent->content_type = g_strdup( LSQ_MIME_DIRECTORY );
+    }
+
+    //g_debug("i: %s", filename);
+    parent->buffer = lsq_btree_insert_sorted_single( parent->buffer, child, (GCompareFunc)lsq_archive_entry_compare );
+
+    /* Cache the length so we doen't have to check every time */
+    ++parent->buffer_length;
+
+    if ( LSQ_ENTRY_CHILD_BUFFER_SIZE == parent->buffer_length )
+    {
+        lsq_archive_entry_flush_buffer( parent );
+    }
+
+    return child;
 }
 
 static gint
-lsq_archive_entry_filename_compare(const gchar *a_filename, LSQArchiveEntry *b)
+lsq_archive_entry_filename_compare ( const gchar *a_filename, LSQArchiveEntry *b )
 {
-	return strcmp(a_filename, b->filename);
+    return strcmp( a_filename, b->filename );
 }
 
 static gboolean
-lsq_archive_entry_remove_child(LSQArchiveEntry *entry, const gchar *filename)
+lsq_archive_entry_remove_child ( LSQArchiveEntry *entry, const gchar *filename )
 {
-	/* the first element of the array (*entry->children) contains the size of the array */
-	guint total_size, size = total_size = entry->children?GPOINTER_TO_UINT(*entry->children):0;
-	guint pos = 0;
-	guint begin = 1;
-	gint cmp = 0;
-	const gchar *_pos = strchr(filename, '/');
-	gchar *_filename;
-	LSQArchiveEntry *found = NULL;
-
-	if ( 0 != _pos )
-	{
-		_filename = g_strndup(filename, (gsize)(_pos - filename));
-	}
-	else
-	{
-		_filename = g_strdup(filename);
-	}
-
-
-	/* binary search algoritme */
-	while ( 0 != size )
-	{
-		pos = (size / 2);
-
-		cmp = strcmp(_filename, entry->children[begin+pos]->filename);
-		if ( 0 == cmp )
-		{
-			g_free(_filename);
-			for ( ;(begin + pos) < total_size; ++pos )
-			{
-				entry->children[begin+pos] = entry->children[begin+pos+1];
-			}
-			total_size -= 1;
-			*entry->children = GUINT_TO_POINTER(total_size);
-			return TRUE;
-		}
-
-		if ( 0 > cmp )
-		{
-			size = pos;
-		}
-		else
-		{
-			size -= ++pos;
-			begin += pos;
-		}
-	}
-
-	/* search the buffer */
-	entry->buffer = lsq_btree_remove_sorted_single(entry->buffer, _filename, (GCompareFunc)lsq_archive_entry_filename_compare, &found);
-
-	g_free(_filename);
-	return NULL != found;
+    /* the first element of the array (*entry->children) contains the size of the array */
+    guint total_size, size = total_size = 0;
+    guint pos = 0;
+    guint begin = 1;
+    gint cmp = 0;
+    gchar *_pos;
+    gchar *_filename;
+    LSQArchiveEntry *found = NULL;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != entry, FALSE );
+    g_return_val_if_fail( NULL != filename, FALSE );
+#endif
+
+    if ( NULL != entry->children )
+    {
+        size = total_size = GPOINTER_TO_UINT( *entry->children );
+    }
+
+    _pos = strchr( filename, '/' );
+
+    if ( 0 != _pos )
+    {
+        _filename = g_strndup( filename, (gsize)(_pos - filename) );
+    }
+    else
+    {
+        _filename = g_strdup( filename );
+    }
+
+    /* binary search algoritme */
+    while ( 0 != size )
+    {
+        pos = ( size / 2 );
+
+        cmp = strcmp( _filename, entry->children[begin+pos]->filename );
+        if ( 0 == cmp )
+        {
+            g_free( _filename );
+            for ( ;( begin + pos ) < total_size; ++pos )
+            {
+                entry->children[begin+pos] = entry->children[begin+pos+1];
+            }
+            total_size -= 1;
+            *entry->children = GUINT_TO_POINTER( total_size );
+            return TRUE;
+        }
+
+        if ( 0 > cmp )
+        {
+            size = pos;
+        }
+        else
+        {
+            size -= ++pos;
+            begin += pos;
+        }
+    }
+
+    /* search the buffer */
+    entry->buffer = lsq_btree_remove_sorted_single( entry->buffer, _filename, (GCompareFunc)lsq_archive_entry_filename_compare, &found );
+
+    g_free( _filename );
+    return NULL != found;
 }
 
-inline static const gchar*
-lsq_archive_entry_get_prop_str(const LSQArchive *archive, const LSQArchiveEntry *entry, guint i)
+inline static const gchar *
+lsq_archive_entry_get_prop_str ( const LSQArchive *archive, const LSQArchiveEntry *entry, guint i )
 {
-	const gchar *retval = NULL;
-	gpointer props_iter = NULL; 
-	guint offset;
-
-	switch(i)
-	{
-		case LSQ_ARCHIVE_PROP_FILENAME:
-			retval = lsq_archive_entry_get_filename(entry);
-			break;
-		case LSQ_ARCHIVE_PROP_MIME_TYPE:
-			retval = lsq_archive_entry_get_contenttype(entry);
-			break;
-		default:
-			props_iter = entry->props;
-			if(props_iter)
-			{
-			  if ( G_TYPE_STRING == lsq_archive_get_entry_property_type(archive, i) )
-			  {
-				offset = lsq_archive_get_entry_property_offset(archive, i);
-
-				retval = (((gchar **)props_iter)[offset]);
-			  }
-			}
-			break;
-	}
-	return retval;
+    const gchar *retval = NULL;
+    gpointer props_iter = NULL; 
+    guint offset;
+
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+    g_return_val_if_fail( NULL != entry, NULL );
+    g_return_val_if_fail( lsq_archive_n_entry_properties( archive ) > i, NULL );
+#endif
+
+    switch ( i )
+    {
+        case LSQ_ARCHIVE_PROP_FILENAME:
+            retval = lsq_archive_entry_get_filename( entry );
+            break;
+
+        case LSQ_ARCHIVE_PROP_MIME_TYPE:
+            retval = lsq_archive_entry_get_contenttype( entry );
+            break;
+
+        default:
+            props_iter = entry->props;
+            if ( NULL != props_iter )
+            {
+                if ( G_TYPE_STRING == lsq_archive_get_entry_property_type( archive, i ) )
+                {
+                    offset = lsq_archive_get_entry_property_offset( archive, i );
+
+                    retval = (((gchar **)props_iter)[offset]);
+                }
+#ifdef DEBUG
+                else
+                {
+                    g_warn_if_reached();
+                }
+#endif
+            }
+            break;
+    }
+    return retval;
 }
 
 inline static guint
-lsq_archive_entry_get_prop_uint(const LSQArchive *archive, const LSQArchiveEntry *entry, guint i)
+lsq_archive_entry_get_prop_uint ( const LSQArchive *archive, const LSQArchiveEntry *entry, guint i )
 {
-	gpointer props_iter = entry->props;
-	guint offset;
-	if ( NULL == props_iter )
-	{
-		return 0;
-	}
+    gpointer props_iter;
+    guint offset;
 
-	if ( G_TYPE_UINT != lsq_archive_get_entry_property_type(archive, i) )
-	{
-		return 0;
-	}
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), 0 );
+    g_return_val_if_fail( NULL != entry, 0 );
+    g_return_val_if_fail( LSQ_ARCHIVE_PROP_USER <= i, 0 );
+    g_return_val_if_fail( lsq_archive_n_entry_properties( archive ) > i, 0 );
+#endif
 
-	offset = lsq_archive_get_entry_property_offset(archive, i);
+    props_iter = entry->props;
 
-	return (((guint *)props_iter)[offset]);
+    if ( NULL == props_iter )
+    {
+        return 0;
+    }
+
+    if ( G_TYPE_UINT != lsq_archive_get_entry_property_type( archive, i ) )
+    {
+#ifdef DEBUG
+        g_warn_if_reached();
+#endif
+        return 0;
+    }
+
+    offset = lsq_archive_get_entry_property_offset( archive, i );
+
+    return (((guint *)props_iter)[offset]);
 }
 
 inline static guint64
-lsq_archive_entry_get_prop_uint64(const LSQArchive *archive, const LSQArchiveEntry *entry, guint i)
+lsq_archive_entry_get_prop_uint64 ( const LSQArchive *archive, const LSQArchiveEntry *entry, guint i )
 {
-	gpointer props_iter = entry->props;
-	guint offset;
-	if ( NULL == props_iter )
-	{
-		return 0;
-	}
+    gpointer props_iter;
+    guint offset;
+
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), 0 );
+    g_return_val_if_fail( NULL != entry, 0 );
+    g_return_val_if_fail( LSQ_ARCHIVE_PROP_USER <= i, 0 );
+    g_return_val_if_fail( lsq_archive_n_entry_properties( archive ) > i, 0 );
+#endif
 
-	if ( G_TYPE_UINT64 != lsq_archive_get_entry_property_type(archive, i) )
-	{
-		return 0;
-	}
+    props_iter = entry->props;
 
-	offset = lsq_archive_get_entry_property_offset(archive, i);
+    if ( NULL == props_iter )
+    {
+        return 0;
+    }
 
-	return (((guint64 *)props_iter)[offset]);
+    if ( G_TYPE_UINT64 != lsq_archive_get_entry_property_type( archive, i ) )
+    {
+#ifdef DEBUG
+        g_warn_if_reached();
+#endif
+        return 0;
+    }
+
+    offset = lsq_archive_get_entry_property_offset( archive, i );
+
+    return (((guint64 *)props_iter)[offset]);
 }
 
 inline static LSQDateTime
-lsq_archive_entry_get_prop_datetime(const LSQArchive *archive, const LSQArchiveEntry *entry, guint i)
+lsq_archive_entry_get_prop_datetime ( const LSQArchive *archive, const LSQArchiveEntry *entry, guint i )
 {
-	gpointer props_iter = entry->props;
-	guint offset;
-	if ( NULL == props_iter )
-	{
-		return 0;
-	}
+    gpointer props_iter;
+    guint offset;
+
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), LSQ_DATETIME_NULL );
+    g_return_val_if_fail( NULL != entry, LSQ_DATETIME_NULL );
+    g_return_val_if_fail( LSQ_ARCHIVE_PROP_USER <= i, LSQ_DATETIME_NULL );
+    g_return_val_if_fail( lsq_archive_n_entry_properties( archive ) > i, LSQ_DATETIME_NULL );
+#endif
+
+    props_iter = entry->props;
 
-	if ( LSQ_TYPE_DATETIME != lsq_archive_get_entry_property_type(archive, i) )
-	{
-		return 0;
-	}
+    if ( NULL == props_iter )
+    {
+        return LSQ_DATETIME_NULL;
+    }
 
-	offset = lsq_archive_get_entry_property_offset(archive, i);
+    if ( LSQ_TYPE_DATETIME != lsq_archive_get_entry_property_type( archive, i ) )
+    {
+#ifdef DEBUG
+        g_warn_if_reached();
+#endif
+        return LSQ_DATETIME_NULL;
+    }
 
-	return (((LSQDateTime *)props_iter)[offset]);
+    offset = lsq_archive_get_entry_property_offset( archive, i );
+
+    return (((LSQDateTime *)props_iter)[offset]);
 }
 
 static gpointer
-lsq_archive_entry_get_props(const LSQArchive *archive, LSQArchiveEntry *entry)
+lsq_archive_entry_get_props ( const LSQArchive *archive, LSQArchiveEntry *entry )
 {
-	guint size = 0;
+    guint size = 0;
 
-	if ( NULL == entry->props )
-	{
-		size = lsq_archive_entry_properties_size(archive);
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+    g_return_val_if_fail( NULL != entry, NULL );
+#endif
+
+    if ( NULL == entry->props )
+    {
+        size = lsq_archive_entry_properties_size( archive );
 
-		entry->props = g_malloc0(size);
-	}
+        entry->props = g_malloc0( size );
+    }
 
-	return entry->props;
+    return entry->props;
 }
 
 static void
-lsq_archive_entry_set_prop_str(const LSQArchive *archive, LSQArchiveEntry *entry, guint n, gchar *str_val)
+lsq_archive_entry_set_prop_str ( const LSQArchive *archive, LSQArchiveEntry *entry, guint n, gchar *str_val )
 {
-	gpointer props_iter = lsq_archive_entry_get_props(archive, entry);
-	guint offset;
+    gpointer props_iter;
+    guint offset;
 
-	if ( G_TYPE_STRING != lsq_archive_get_entry_property_type(archive, n) )
-	{
-		return;
-	}
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+    g_return_if_fail( NULL != entry );
+    g_return_if_fail( LSQ_ARCHIVE_PROP_USER <= n );
+    g_return_if_fail( lsq_archive_n_entry_properties( archive ) > n );
+#endif
+
+    props_iter = lsq_archive_entry_get_props( archive, entry );
 
-	offset = lsq_archive_get_entry_property_offset(archive, n);
+    if ( G_TYPE_STRING != lsq_archive_get_entry_property_type( archive, n ) )
+    {
+#ifdef DEBUG
+        g_warn_if_reached();
+#endif
+        return;
+    }
 
-	g_free(((gchar **)props_iter)[offset]);
-	((gchar **)props_iter)[offset] = str_val; /* We take ownership */
+    offset = lsq_archive_get_entry_property_offset( archive, n );
+
+    g_free( ((gchar **)props_iter)[offset] );
+    ((gchar **)props_iter)[offset] = str_val; /* We take ownership */
 }
 
 static void
-lsq_archive_entry_set_prop_uint(const LSQArchive *archive, LSQArchiveEntry *entry, guint n, guint int_val)
+lsq_archive_entry_set_prop_uint ( const LSQArchive *archive, LSQArchiveEntry *entry, guint n, guint int_val )
 {
-	gpointer props_iter = lsq_archive_entry_get_props(archive, entry);
-	guint offset;
+    gpointer props_iter;
+    guint offset;
 
-	if ( G_TYPE_UINT != lsq_archive_get_entry_property_type(archive, n) )
-	{
-		return;
-	}
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+    g_return_if_fail( NULL != entry );
+    g_return_if_fail( LSQ_ARCHIVE_PROP_USER <= n );
+    g_return_if_fail( lsq_archive_n_entry_properties( archive ) > n );
+#endif
 
-	offset = lsq_archive_get_entry_property_offset(archive, n);
+    props_iter = lsq_archive_entry_get_props( archive, entry );
 
-	((guint *)props_iter)[offset] = int_val;
+    if ( G_TYPE_UINT != lsq_archive_get_entry_property_type( archive, n ) )
+    {
+#ifdef DEBUG
+        g_warn_if_reached();
+#endif
+        return;
+    }
+
+    offset = lsq_archive_get_entry_property_offset( archive, n );
+
+    ((guint *)props_iter)[offset] = int_val;
 }
 
 static void
-lsq_archive_entry_set_prop_uint64(const LSQArchive *archive, LSQArchiveEntry *entry, guint n, guint64 int64_val)
+lsq_archive_entry_set_prop_uint64 ( const LSQArchive *archive, LSQArchiveEntry *entry, guint n, guint64 int64_val )
 {
-	gpointer props_iter = lsq_archive_entry_get_props(archive, entry);
-	guint offset;
+    gpointer props_iter;
+    guint offset;
 
-	if ( G_TYPE_UINT64 !=  lsq_archive_get_entry_property_type(archive, n) )
-	{
-		return;
-	}
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+    g_return_if_fail( NULL != entry );
+    g_return_if_fail( LSQ_ARCHIVE_PROP_USER <= n );
+    g_return_if_fail( lsq_archive_n_entry_properties( archive ) > n );
+#endif
 
-	offset = lsq_archive_get_entry_property_offset(archive, n);
+    props_iter = lsq_archive_entry_get_props( archive, entry );
 
-	((guint64 *)props_iter)[offset] = int64_val;
+    if ( G_TYPE_UINT64 !=  lsq_archive_get_entry_property_type( archive, n ) )
+    {
+#ifdef DEBUG
+        g_warn_if_reached();
+#endif
+        return;
+    }
+
+    offset = lsq_archive_get_entry_property_offset( archive, n );
+
+    ((guint64 *)props_iter)[offset] = int64_val;
 }
 
 static void
-lsq_archive_entry_set_prop_datetime(const LSQArchive *archive, LSQArchiveEntry *entry, guint n, LSQDateTime dt_val)
+lsq_archive_entry_set_prop_datetime ( const LSQArchive *archive, LSQArchiveEntry *entry, guint n, LSQDateTime dt_val )
 {
-	gpointer props_iter = lsq_archive_entry_get_props(archive, entry);
-	guint offset;
+    gpointer props_iter = lsq_archive_entry_get_props( archive, entry );
+    guint offset;
 
-	if ( LSQ_TYPE_DATETIME != lsq_archive_get_entry_property_type(archive, n) )
-	{
-		return;
-	}
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+    g_return_if_fail( NULL != entry );
+    g_return_if_fail( LSQ_ARCHIVE_PROP_USER <= n );
+    g_return_if_fail( lsq_archive_n_entry_properties( archive ) > n );
+#endif
 
-	offset = lsq_archive_get_entry_property_offset(archive, n);
+    props_iter = lsq_archive_entry_get_props( archive, entry );
 
-	((LSQDateTime *)props_iter)[offset] = dt_val; /* We take ownership */
+    if ( LSQ_TYPE_DATETIME != lsq_archive_get_entry_property_type( archive, n ) )
+    {
+#ifdef DEBUG
+        g_warn_if_reached();
+#endif
+        return;
+    }
+
+    offset = lsq_archive_get_entry_property_offset( archive, n );
+
+    ((LSQDateTime *)props_iter)[offset] = dt_val; /* We take ownership */
 }
 
 static void
-lsq_archive_entry_set_propsv(const LSQArchive *archive, LSQArchiveEntry *entry, gpointer *props)
+lsq_archive_entry_set_propsv ( const LSQArchive *archive, LSQArchiveEntry *entry, gpointer *props )
 {
-	gpointer props_iter = lsq_archive_entry_get_props(archive, entry);
-	guint offset;
-	guint i;
-
-	for(i=0; i < (lsq_archive_n_entry_properties(archive) - LSQ_ARCHIVE_PROP_USER); ++i)
-	{
-		offset = lsq_archive_get_entry_property_offset(archive, i+LSQ_ARCHIVE_PROP_USER);
-		switch(lsq_archive_get_entry_property_type(archive, i+LSQ_ARCHIVE_PROP_USER))
-		{
-			case G_TYPE_STRING:
-				g_free(((gchar **)props_iter)[offset]);
-				//(*((gchar **)props_iter)) = g_strdup((const gchar*)props[i]);
-				((gchar **)props_iter)[offset] = (gchar*)props[i]; /* We take ownership */
-				break;
-			case G_TYPE_UINT:
-				((guint *)props_iter)[offset] = *((const guint *)props[i]);
-				break;
-			case G_TYPE_UINT64:
-				((guint64 *)props_iter)[offset] = *((const guint64 *)props[i]);
-				break;
-                        default:
-                                if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type(archive, i+LSQ_ARCHIVE_PROP_USER) )
-                                {
-                                    ((LSQDateTime *)props_iter)[offset] = *(LSQDateTime*)props[i];
-                                    break;
-                                }
-				break;
-		}
-	}
+    gpointer props_iter;
+    guint offset;
+    guint i;
+
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+    g_return_if_fail( NULL != entry );
+    g_return_if_fail( NULL != props );
+    g_return_if_fail( NULL == props[lsq_archive_n_entry_properties( archive ) - LSQ_ARCHIVE_PROP_USER] );
+#endif
+
+    props_iter = lsq_archive_entry_get_props( archive, entry );
+
+    for ( i = 0; i < ( lsq_archive_n_entry_properties( archive ) - LSQ_ARCHIVE_PROP_USER ); ++i )
+    {
+        offset = lsq_archive_get_entry_property_offset( archive, i + LSQ_ARCHIVE_PROP_USER );
+        switch ( lsq_archive_get_entry_property_type( archive, i + LSQ_ARCHIVE_PROP_USER ) )
+        {
+            case G_TYPE_STRING:
+                g_free( ((gchar **)props_iter)[offset] );
+                //(*((gchar **)props_iter)) = g_strdup((const gchar *)props[i]);
+                ((gchar **)props_iter)[offset] = (gchar *)props[i]; /* We take ownership */
+                break;
+
+            case G_TYPE_UINT:
+                ((guint *)props_iter)[offset] = *((const guint *)props[i]);
+                break;
+
+            case G_TYPE_UINT64:
+                ((guint64 *)props_iter)[offset] = *((const guint64 *)props[i]);
+                break;
+
+            default:
+                if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type( archive, i + LSQ_ARCHIVE_PROP_USER ) )
+                {
+                  ((LSQDateTime *)props_iter)[offset] = *(LSQDateTime *)props[i];
+                  break;
+                }
+#ifdef DEBUG
+                g_warn_if_reached();
+#endif
+                break;
+        }
+    }
 }
 
 static void
-lsq_archive_entry_set_propsva(const LSQArchive *archive, LSQArchiveEntry *entry, va_list ap)
+lsq_archive_entry_set_propsva ( const LSQArchive *archive, LSQArchiveEntry *entry, va_list ap )
 {
-	gpointer props_iter = lsq_archive_entry_get_props(archive, entry);
-	guint offset;
-	guint i;
-
-	for(i=0; i < (lsq_archive_n_entry_properties(archive) - LSQ_ARCHIVE_PROP_USER); ++i)
-	{
-		offset = lsq_archive_get_entry_property_offset(archive, i+LSQ_ARCHIVE_PROP_USER);
-		switch(lsq_archive_get_entry_property_type(archive, i+LSQ_ARCHIVE_PROP_USER))
-		{
-			case G_TYPE_STRING:
-				g_free(((gchar **)props_iter)[offset]);
-				((gchar **)props_iter)[offset] = va_arg(ap, gchar*); /* We take ownership */
-				break;
-			case G_TYPE_UINT:
-				((guint *)props_iter)[offset] = va_arg(ap, guint);
-				break;
-			case G_TYPE_UINT64:
-				((guint64 *)props_iter)[offset] = va_arg(ap, guint64);
-				break;
-                        default:
-                                if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type(archive, i+LSQ_ARCHIVE_PROP_USER) )
-                                {
-                                    ((LSQDateTime *)props_iter)[offset] = va_arg(ap, LSQDateTime);
-                                    break;
-                                }
-				break;
-		}
-	}
+    gpointer props_iter;
+    guint offset;
+    guint i;
+
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+    g_return_if_fail( NULL != entry );
+    g_return_if_fail( NULL != ap );
+#endif
+
+    props_iter = lsq_archive_entry_get_props( archive, entry );
+
+    for ( i = LSQ_ARCHIVE_PROP_USER; i < ( lsq_archive_n_entry_properties( archive ) ); ++i )
+    {
+        offset = lsq_archive_get_entry_property_offset( archive, i );
+        switch ( lsq_archive_get_entry_property_type( archive, i ) )
+        {
+            case G_TYPE_STRING:
+                g_free( ((gchar **)props_iter)[offset] );
+                ((gchar **)props_iter)[offset] = va_arg( ap, gchar * ); /* We take ownership */
+                break;
+            case G_TYPE_UINT:
+                ((guint *)props_iter)[offset] = va_arg( ap, guint );
+                break;
+            case G_TYPE_UINT64:
+                ((guint64 *)props_iter)[offset] = va_arg( ap, guint64 );
+                break;
+            default:
+                if ( LSQ_TYPE_DATETIME == lsq_archive_get_entry_property_type( archive, i ) )
+                {
+                    ((LSQDateTime *)props_iter)[offset] = va_arg( ap, LSQDateTime );
+                    break;
+                }
+#ifdef DEBUG
+                g_warn_if_reached();
+#endif
+                break;
+        }
+    }
 }
 
 /******************************
@@ -1610,83 +1922,91 @@ lsq_archive_entry_set_propsva(const LSQArchive *archive, LSQArchiveEntry *entry,
  ******************************/
 
 static gchar *
-lsq_concat_child_filenames(LSQArchiveIter *iter)
+lsq_concat_child_filenames ( LSQArchiveIter *iter )
 {
-	gchar *concat_str;
-	guint i, size = lsq_archive_iter_n_children(iter);
-	LSQArchiveIter *child;
-	gchar **part = g_new(gchar*, (size*2)+1);
-	part[size*2] = NULL;
-	for ( i=0; i < size; i++ )
-	{
-		gchar *path;
-		child = lsq_archive_iter_nth_child(iter, i);
-
-		part[i*2] = lsq_concat_child_filenames(child);
-		path = lsq_archive_iter_get_path(child);
-		part[(i*2)+1] = g_shell_quote(path);
-		g_free(path);
-
-		lsq_archive_iter_unref(child);
-	}
-	concat_str = g_strjoinv(" ", part);
-	g_strfreev(part);
-	return concat_str;
+    gchar *concat_str;
+    guint i, size;
+    LSQArchiveIter *child;
+    gchar **part;
+
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != iter, NULL );
+#endif
+
+    size = lsq_archive_iter_n_children( iter );
+    part = g_new( gchar *, ( size * 2 ) + 1 );
+    part[size*2] = NULL;
+
+    for ( i = 0; i < size; i++ )
+    {
+        gchar *path;
+        child = lsq_archive_iter_nth_child( iter, i );
+
+        part[i*2] = lsq_concat_child_filenames( child );
+        path = lsq_archive_iter_get_path( child );
+        part[(i*2)+1] = g_shell_quote( path );
+        g_free( path );
+
+        lsq_archive_iter_unref( child );
+    }
+    concat_str = g_strjoinv( " ", part );
+    g_strfreev( part );
+    return concat_str;
 }
 
 gchar *
-lsq_concat_iter_filenames(GSList *file_iters, gboolean recursive)
+lsq_concat_iter_filenames ( GSList *file_iters, gboolean recursive )
 {
-	GSList *iter = file_iters;
-	gchar *concat_str = g_strdup(""), *_concat_str;
-	gchar *children = "";
-	for ( iter = file_iters; NULL != iter; iter = iter->next )
-	{
-		gchar *path = lsq_archive_iter_get_path(iter->data);
-		gchar *quote = g_shell_quote(path);
-		g_free(path);
-
-		if ( TRUE == recursive )
-		{
-			children = lsq_concat_child_filenames(iter->data);
-		}
-
-		_concat_str = concat_str;
-		concat_str = g_strconcat(_concat_str, " ", children, " ", quote , NULL);
-		g_free(_concat_str);
-
-		if ( TRUE == recursive )
-		{
-			g_free(children);
-		}
-
-		g_free(quote);
-	}
-	return concat_str;
+    GSList *iter = file_iters;
+    gchar *concat_str = g_strdup( "" ), *_concat_str;
+    gchar *children = "";
+    for ( iter = file_iters; NULL != iter; iter = iter->next )
+    {
+        gchar *path = lsq_archive_iter_get_path( iter->data );
+        gchar *quote = g_shell_quote( path );
+        g_free( path );
+
+        if ( TRUE == recursive )
+        {
+            children = lsq_concat_child_filenames( iter->data );
+        }
+
+        _concat_str = concat_str;
+        concat_str = g_strconcat( _concat_str, " ", children, " ", quote , NULL );
+        g_free( _concat_str );
+
+        if ( TRUE == recursive )
+        {
+            g_free( children );
+        }
+
+        g_free( quote );
+    }
+    return concat_str;
 }
 
 GSList *
-lsq_iter_slist_copy(GSList *iters)
+lsq_iter_slist_copy ( GSList *iters )
 {
-	GSList *new_list = g_slist_copy(iters);
-	GSList *iter;
-	for ( iter = iters; NULL != iter; iter = iter->next )
-	{
-		lsq_archive_iter_ref(iter->data);
-	}
-	//g_slist_foreach(iters, (GFunc)lsq_archive_iter_ref, NULL);
-	return new_list;
+    GSList *new_list = g_slist_copy( iters );
+    GSList *iter;
+    for ( iter = iters; NULL != iter; iter = iter->next )
+    {
+        lsq_archive_iter_ref( iter->data );
+    }
+    //g_slist_foreach(iters, (GFunc)lsq_archive_iter_ref, NULL);
+    return new_list;
 }
 
 void
-lsq_iter_slist_free(GSList *iters)
+lsq_iter_slist_free ( GSList *iters )
 {
-	GSList *iter;
-	for ( iter = iters; NULL != iter; iter = iter->next )
-	{
-		lsq_archive_iter_unref(iter->data);
-	}
-	//g_slist_foreach(iters, (GFunc)lsq_archive_iter_unref, NULL);
-	g_slist_free(iters);
+    GSList *iter;
+    for ( iter = iters; NULL != iter; iter = iter->next )
+    {
+        lsq_archive_iter_unref( iter->data );
+    }
+    //g_slist_foreach(iters, (GFunc)lsq_archive_iter_unref, NULL);
+    g_slist_free( iters );
 }
 
diff --git a/libsqueeze/archive-iter.h b/libsqueeze/archive-iter.h
index 4a4b105..49eaa1a 100644
--- a/libsqueeze/archive-iter.h
+++ b/libsqueeze/archive-iter.h
@@ -21,38 +21,80 @@ G_BEGIN_DECLS
 
 struct _LSQArchiveIter
 {
-	LSQArchive *archive;
-	LSQArchiveEntry *entry;
-	LSQArchiveIter *parent;
-	guint ref_count;
+    LSQArchive *archive;
+    LSQArchiveEntry *entry;
+    LSQArchiveIter *parent;
+    guint ref_count;
 };
 
-void	 lsq_archive_init_iter(LSQArchive *);
-void	 lsq_archive_free_iter(LSQArchive *);
+void
+lsq_archive_init_iter ( LSQArchive * );
+void
+lsq_archive_free_iter ( LSQArchive * );
 
 
-void	 lsq_archive_iter_remove(LSQArchiveIter *, gboolean);
+void
+lsq_archive_iter_remove (
+        LSQArchiveIter *,
+        gboolean
+    );
 
 #ifdef DEBUG
-LSQArchiveIter *_lsq_archive_iter_ref(LSQArchiveIter *iter, const gchar*, int);
-void			_lsq_archive_iter_unref(LSQArchiveIter *iter, const gchar*, int);
+LSQArchiveIter *
+_lsq_archive_iter_ref (
+        LSQArchiveIter *iter,
+        const gchar *
+    );
+void
+_lsq_archive_iter_unref (
+        LSQArchiveIter *iter,
+        const gchar *
+    );
 /*
-#define lsq_archive_iter_ref(iter) _lsq_archive_iter_ref(iter, __FILE__, __LINE__)
-#define lsq_archive_iter_unref(iter) _lsq_archive_iter_unref(iter, __FILE__, __LINE__)
+#define lsq_archive_iter_ref(iter) _lsq_archive_iter_ref(iter, G_STRLOC)
+#define lsq_archive_iter_unref(iter) _lsq_archive_iter_unref(iter, G_STRLOC)
 */
 #endif
 
-LSQArchiveIter *lsq_archive_iter_ref(LSQArchiveIter *iter);
-void			lsq_archive_iter_unref(LSQArchiveIter *iter);
+LSQArchiveIter *
+lsq_archive_iter_ref ( LSQArchiveIter *iter );
+void
+lsq_archive_iter_unref ( LSQArchiveIter *iter );
 
-LSQArchiveIter *lsq_archive_add_file(LSQArchive *archive, const gchar *path);
+LSQArchiveIter *
+lsq_archive_add_file (
+        LSQArchive *archive,
+        const gchar *path
+    ) G_GNUC_WARN_UNUSED_RESULT;
 
-LSQArchiveIter *lsq_archive_iter_add_file(LSQArchiveIter *parent, const gchar *filename);
+LSQArchiveIter *
+lsq_archive_iter_add_file (
+        LSQArchiveIter *parent,
+        const gchar *filename
+    ) G_GNUC_WARN_UNUSED_RESULT;
 
-void  lsq_archive_iter_set_prop_value(LSQArchiveIter *iter, guint n, const GValue *value);
-void  lsq_archive_iter_set_prop(LSQArchiveIter *iter, guint n, gpointer value);
-void  lsq_archive_iter_set_props(LSQArchiveIter *iter, ...);
-void  lsq_archive_iter_set_propsv(LSQArchiveIter *iter, gpointer *props);
+void
+lsq_archive_iter_set_prop_value (
+        LSQArchiveIter *iter,
+        guint n,
+        const GValue *value
+    );
+void
+lsq_archive_iter_set_prop (
+        LSQArchiveIter *iter,
+        guint n,
+        gpointer value
+    );
+void
+lsq_archive_iter_set_props (
+        LSQArchiveIter *iter,
+        ...
+    ) G_GNUC_NULL_TERMINATED;
+void
+lsq_archive_iter_set_propsv (
+        LSQArchiveIter *iter,
+        gpointer *props
+    );
 
 G_END_DECLS
 
diff --git a/libsqueeze/archive-tempfs.c b/libsqueeze/archive-tempfs.c
index 210bef2..8d8155b 100644
--- a/libsqueeze/archive-tempfs.c
+++ b/libsqueeze/archive-tempfs.c
@@ -44,36 +44,30 @@ lsq_tempfs_clean_dir ( const gchar *path )
     const gchar *file;
     GDir *dir;
 
-    /* Is this a valid use-case?
-     * Shouldn't this be replaced with an assert?
-     */
-    if ( NULL == path )
-    {
-        return;
-    }
+    g_return_if_fail( NULL != path );
 
     dir = g_dir_open ( path, 0, NULL );
 
     if ( NULL != dir )
     {
-        file = g_dir_read_name ( dir );
+        file = g_dir_read_name( dir );
 
         while ( NULL != file )
         {
-            file = g_strconcat (
+            file = g_build_filename(
                     path,   
-                    "/",
                     file,
-                    NULL);
-            lsq_tempfs_clean_dir ( file );
-            g_free ( (gchar*)file );
-            file = g_dir_read_name ( dir );
+                    NULL
+                );
+            lsq_tempfs_clean_dir( file );
+            g_free( (gchar *)file );
+            file = g_dir_read_name( dir );
         }
 
-        g_dir_close ( dir );
+        g_dir_close( dir );
     }
 
-    g_remove(path);
+    g_remove( path );
 }
 
 void
@@ -81,37 +75,41 @@ lsq_tempfs_clean_root_dir ( LSQArchive *archive )
 {
     GSList *iter;
 
-    if ( NULL != archive->temp_dir )
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+
+    if ( NULL == archive->temp_dir )
     {
         return;
     }
 
-    lsq_tempfs_clean_dir ( archive->temp_dir );
+    lsq_tempfs_clean_dir( archive->temp_dir );
 
 #ifdef DEBUG
-    g_debug("clean %s", archive->temp_dir);
+    g_debug( "clean %s", archive->temp_dir );
 #endif
 
     iter = archive->monitor_list;
     while ( NULL != iter )
     {
     /*    g_free(((LSQTempFileMonitor*)iter->data)->filename); */
-        g_free ( iter->data );
-        iter = g_slist_next ( iter );
+        g_free( iter->data );
+        iter = g_slist_next( iter );
     }
-    g_slist_free ( archive->monitor_list );
+    g_slist_free( archive->monitor_list );
     archive->monitor_list = NULL;
 
-    g_free ( archive->temp_dir );
+    g_free( archive->temp_dir );
     archive->temp_dir = NULL;
 }
 
-const gchar*
+const gchar *
 lsq_tempfs_get_root_dir ( LSQArchive *archive )
 {
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+
     if ( NULL != archive->temp_dir )
     {
-        if ( FALSE == lsq_tempfs_make_root_dir ( archive ) )
+        if ( FALSE == lsq_tempfs_make_root_dir( archive ) )
         {
             return NULL;
         }
@@ -123,28 +121,32 @@ lsq_tempfs_get_root_dir ( LSQArchive *archive )
 gboolean
 lsq_tempfs_make_root_dir ( LSQArchive *archive )
 {
-    gboolean error = FALSE;
+    gint error = 0;
     gchar dirname[256];
 
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), FALSE );
+
     if ( NULL != archive->temp_dir )
     {
         return TRUE;
     }
 
-    g_snprintf(dirname, 256, "%s/" PACKAGE "-%s/", g_get_tmp_dir(), g_get_user_name());
-    if(g_mkdir_with_parents(dirname, 0700))
+    g_snprintf( dirname, 256, "%s/" PACKAGE "-%s/", g_get_tmp_dir(), g_get_user_name() );
+    if ( 0 != g_mkdir_with_parents( dirname, 0700 ) )
+    {
         return FALSE;
+    }
 
     do
     {
-        g_snprintf(dirname, 256, "%s/" PACKAGE "-%s/cache-%d/", g_get_tmp_dir(), g_get_user_name(), suffix++);
-        error = g_mkdir(dirname, 0700);
+        g_snprintf( dirname, 256, "%s/" PACKAGE "-%s/cache-%d/", g_get_tmp_dir(), g_get_user_name(), suffix++ );
+        error = g_mkdir( dirname, 0700 );
     }
-    while(error && errno == EEXIST);
+    while ( 0 != error && EEXIST == errno );
 
-    if ( FALSE == error )
+    if ( 0 == error )
     {
-        archive->temp_dir = g_strdup ( dirname );
+        archive->temp_dir = g_strdup( dirname );
         return TRUE;
     }
 
@@ -154,60 +156,68 @@ lsq_tempfs_make_root_dir ( LSQArchive *archive )
 gchar *
 lsq_archive_request_temp_file (
         LSQArchive *archive,
-        const gchar *sfx )
+        const gchar *sfx
+    )
 {
     gchar dirname[256];
     gint handle;
 
-    g_snprintf(dirname, 256, "%s/" PACKAGE "-%s/", g_get_tmp_dir(), g_get_user_name());
-    if ( 0 != g_mkdir_with_parents ( dirname, 0700 ) )
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+
+    g_snprintf( dirname, 256, "%s/" PACKAGE "-%s/", g_get_tmp_dir(), g_get_user_name() );
+    if ( 0 != g_mkdir_with_parents( dirname, 0700 ) )
     {
-        return FALSE;
+        return NULL;
     }
 
-    g_snprintf(dirname, 256, "%s/" PACKAGE "-%s/file-XXXXXX%s", g_get_tmp_dir(), g_get_user_name(), sfx?sfx:"");
+    g_snprintf( dirname, 256, "%s/" PACKAGE "-%s/file-XXXXXX%s", g_get_tmp_dir(), g_get_user_name(), ( NULL != sfx ) ? sfx : "" );
 
-    handle = g_mkstemp ( dirname );
+    handle = g_mkstemp( dirname );
     if ( -1 == handle )
     {
         return NULL;
     }
 
-    close ( handle );
+    close( handle );
 
-    return strdup ( dirname );
+    return g_strdup( dirname );
 }
 
 gboolean
 lsq_tempfs_make_dir (
         LSQArchive *archive,
         const gchar *path,
-        gint mode )
+        gint mode
+    )
 {
     gchar *full_path;
-    gboolean error;
+    gint error;
+
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), FALSE );
+    g_return_val_if_fail( NULL == path, FALSE );
 
     if ( NULL == archive->temp_dir )
     {
-        if ( FALSE == lsq_tempfs_make_root_dir ( archive ) )
+        if ( FALSE == lsq_tempfs_make_root_dir( archive ) )
         {
             return FALSE;
         }
     }
 
-    full_path = g_strconcat (
+    full_path = g_build_filename(
             archive->temp_dir,
-            "/",
             path,
-            NULL);
+            NULL
+        );
 
-    error = g_mkdir_with_parents (
+    error = g_mkdir_with_parents(
             full_path,
-            mode );
+            mode
+        );
 
-    g_free ( full_path );
+    g_free( full_path );
 
-    if (FALSE == error)
+    if ( 0 == error )
     {
         return TRUE;
     }
@@ -224,27 +234,29 @@ lsq_tempfs_chmod (
         gint mode )
 {
     gchar *full_path;
-    gboolean error;
+    gint error;
+
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), FALSE );
+    g_return_val_if_fail( NULL == path, FALSE );
 
     if ( NULL == archive->temp_dir)
     {
-        if ( FALSE == lsq_tempfs_make_root_dir ( archive ) )
+        if ( FALSE == lsq_tempfs_make_root_dir( archive ) )
         {
             return FALSE;
         }
     }
 
-    full_path = g_strconcat (
+    full_path = g_build_filename(
             archive->temp_dir,
-            "/",
             path,
             NULL);
 
-    error = g_chmod ( full_path, mode );
+    error = g_chmod( full_path, mode );
 
-    g_free ( full_path );
+    g_free( full_path );
 
-    if ( FALSE == error )
+    if ( 0 == error )
     {
         return TRUE;
     }
diff --git a/libsqueeze/archive-tempfs.h b/libsqueeze/archive-tempfs.h
index f6f7c92..e7676e5 100644
--- a/libsqueeze/archive-tempfs.h
+++ b/libsqueeze/archive-tempfs.h
@@ -25,7 +25,7 @@
 void
 lsq_tempfs_clean_root_dir ( LSQArchive *archive );
 
-const gchar*
+const gchar *
 lsq_tempfs_get_root_dir ( LSQArchive *archive );
 
 gboolean
@@ -35,26 +35,31 @@ gboolean
 lsq_tempfs_make_dir (
         LSQArchive *archive,
         const gchar *path,
-        gint mode );
+        gint mode
+    );
 
 gboolean
 lsq_tempfs_chmod (
         LSQArchive *archive,
         const gchar *path,
-        gint mode );
+        gint mode
+    );
 
 gboolean
 lsq_tempfs_monitor_file (
         LSQArchive *archive,
-        const gchar *path) G_GNUC_INTERNAL;
+        const gchar *path
+    );
 
 gboolean
 lsq_tempfs_changed_file (
         LSQArchive *archive,
-        const gchar *path) G_GNUC_INTERNAL;
+        const gchar *path
+    );
 
 gchar *
 lsq_archive_request_temp_file (
         LSQArchive *archive,
-        const gchar *suffix);
+        const gchar *suffix
+    ) G_GNUC_WARN_UNUSED_RESULT;
 
diff --git a/libsqueeze/archive.c b/libsqueeze/archive.c
index fdac9f4..b899d8e 100644
--- a/libsqueeze/archive.c
+++ b/libsqueeze/archive.c
@@ -38,87 +38,61 @@
 #include "internals.h"
 
 static void
-lsq_archive_class_init(LSQArchiveClass *archive_class);
-
-static void
-lsq_archive_init(LSQArchive *archive);
-
-static void
-lsq_archive_finalize(GObject *object);
+lsq_archive_finalize ( GObject *object );
 
 
 enum
 {
-	LSQ_ARCHIVE_SIGNAL_STATE_CHANGED = 0,
-	LSQ_ARCHIVE_SIGNAL_COMMAND_TERMINATED,
-	LSQ_ARCHIVE_SIGNAL_REFRESHED,
-	LSQ_ARCHIVE_SIGNAL_COUNT
+    LSQ_ARCHIVE_SIGNAL_STATE_CHANGED = 0,
+    LSQ_ARCHIVE_SIGNAL_COMMAND_TERMINATED,
+    LSQ_ARCHIVE_SIGNAL_REFRESHED,
+    LSQ_ARCHIVE_SIGNAL_COUNT
 };
 
 static gint lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_COUNT];
 
-GType
-lsq_archive_get_type (void)
-{
-	static GType lsq_archive_type = 0;
-
- 	if (!lsq_archive_type)
-	{
- 		static const GTypeInfo lsq_archive_info = 
-		{
-			sizeof (LSQArchiveClass),
-			(GBaseInitFunc) NULL,
-			(GBaseFinalizeFunc) NULL,
-			(GClassInitFunc) lsq_archive_class_init,
-			(GClassFinalizeFunc) NULL,
-			NULL,
-			sizeof (LSQArchive),
-			0,
-			(GInstanceInitFunc) lsq_archive_init,
-			NULL
-		};
-
-		lsq_archive_type = g_type_register_static (G_TYPE_OBJECT, "LSQArchive", &lsq_archive_info, 0);
-	}
-	return lsq_archive_type;
-}
+G_DEFINE_TYPE ( LSQArchive, lsq_archive, G_TYPE_OBJECT );
 
 static void
-lsq_archive_class_init(LSQArchiveClass *archive_class)
+lsq_archive_class_init ( LSQArchiveClass *archive_class )
 {
-	GObjectClass *object_class = G_OBJECT_CLASS(archive_class);
-
-	object_class->finalize = lsq_archive_finalize;
-	lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_STATE_CHANGED] = g_signal_new("state-changed",
-			G_TYPE_FROM_CLASS(archive_class),
-			G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-			0,
-			NULL,
-			NULL,
-			g_cclosure_marshal_VOID__VOID,
-			G_TYPE_NONE,
-			0,
-			NULL);
-	lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_REFRESHED] = g_signal_new("refreshed",
-			G_TYPE_FROM_CLASS(archive_class),
-			G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-			0,
-			NULL,
-			NULL,
-			g_cclosure_marshal_VOID__VOID,
-			G_TYPE_NONE,
-			0,
-			NULL);
+    GObjectClass *object_class = G_OBJECT_CLASS( archive_class );
+
+    object_class->finalize = lsq_archive_finalize;
+    lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_STATE_CHANGED] = g_signal_new(
+            "state-changed",
+            G_TYPE_FROM_CLASS( archive_class ),
+            G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+            0,
+            NULL,
+            NULL,
+            g_cclosure_marshal_VOID__VOID,
+            G_TYPE_NONE,
+            0,
+            NULL
+        );
+    lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_REFRESHED] = g_signal_new(
+            "refreshed",
+            G_TYPE_FROM_CLASS( archive_class ),
+            G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+            0,
+            NULL,
+            NULL,
+            g_cclosure_marshal_VOID__VOID,
+            G_TYPE_NONE,
+            0,
+            NULL
+        );
 }
 
 static void
-lsq_archive_init(LSQArchive *archive)
+lsq_archive_init ( LSQArchive *archive )
 {
-	lsq_archive_init_iter(archive);
+    lsq_archive_init_iter( archive );
 #ifdef LSQ_THREADSAFE
-	g_static_rw_lock_init(&archive->rw_lock);
+    g_static_rw_lock_init( &archive->rw_lock );
 #endif /* LSQ_THREADSAFE */
-	archive->priv = g_new0(LSQArchivePrivate, 1);
+    archive->priv = g_new0( LSQArchivePrivate, 1 );
 }
 
 /** static void
@@ -127,15 +101,15 @@ lsq_archive_init(LSQArchive *archive)
  * 
  */
 static void
-lsq_archive_finalize(GObject *object)
+lsq_archive_finalize ( GObject *object )
 {
-	LSQArchive *archive;
-	g_return_if_fail ( LSQ_IS_ARCHIVE(object) );
-	archive = (LSQArchive *)(object);
+    LSQArchive *archive = LSQ_ARCHIVE( object );
 
-	lsq_archive_free_iter(archive);
-	lsq_tempfs_clean_root_dir(archive);
-	lsq_opened_archive_list = g_slist_remove(lsq_opened_archive_list, object);
+    lsq_archive_free_iter( archive );
+    lsq_tempfs_clean_root_dir( archive );
+    lsq_opened_archive_list = g_slist_remove( lsq_opened_archive_list, object );
+
+    G_OBJECT_CLASS(lsq_archive_parent_class)->finalize( object );
 }
 
 /**
@@ -147,59 +121,74 @@ lsq_archive_finalize(GObject *object)
  *
  */
 LSQArchive *
-lsq_archive_new (GFile *file)
+lsq_archive_new ( GFile *file )
 {
-	LSQArchive *archive;
+    LSQArchive *archive;
     GFileInfo *file_info;
     const gchar *content_type;
     GSList *iter;
+    gchar *_basename;
+
+    /* We don't support no file. We can't get a content type of a NULL pointer */
+    g_return_val_if_fail( G_IS_FILE( file ), NULL );
 
-	archive = g_object_new(lsq_archive_get_type(), NULL);
-
-	if ( NULL != file )
-	{
-	  archive->priv->file = file;
-	  g_object_ref (archive->priv->file);
-	}
-	else
-	{
-		archive->priv->file= NULL;
-	}
-
-
-    file_info = g_file_query_info (file, "standard::content-type,standard::type", 0, NULL, NULL);
-	if ( NULL != file_info )
-	{
-	  content_type = g_file_info_get_attribute_string (file_info, "standard::content-type");
-	  archive->priv->content_type = g_strdup (content_type); 
-	  g_object_unref(file_info);
-	}
+    archive = g_object_new( lsq_archive_get_type(), NULL );
+
+    archive->priv->file = file;
+    g_object_ref( archive->priv->file );
+
+    file_info = g_file_query_info( file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, NULL );
+    if ( NULL != file_info )
+    {
+        content_type = g_file_info_get_attribute_string( file_info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE );
+        archive->priv->content_type = g_strdup( content_type ); 
+        g_object_unref( file_info );
+    }
+    else
+    {
+        /* The file might not exist yet. Get the content type from the file name */
+        _basename = g_file_get_basename( file );
+        if ( NULL != _basename )
+        {
+            archive->priv->content_type = g_content_type_guess( _basename, NULL, 0, NULL );
+        }
+        g_free( _basename );
+    }
+#ifdef DEBUG
+    g_debug( "mime: %s\n", archive->priv->content_type );
+#endif
+    if ( NULL == archive->priv->content_type )
+    {
+        /* Setting the content_type later on is not supported */
 #ifdef DEBUG
-	g_debug("mime: %s\n", archive->priv->content_type);
+        g_debug( "not supported" );
 #endif
+        g_object_unref( archive );
+        return NULL;
+    }
 
-  for ( iter = lsq_mime_support_list; NULL != iter; iter = iter->next )
-  {
-    if ( 0 == strcmp(((LSQSupportTemplate*)iter->data)->content_type, archive->priv->content_type) )
+    for ( iter = lsq_mime_support_list; NULL != iter; iter = iter->next )
     {
+        if ( 0 == strcmp( ((LSQSupportTemplate *)iter->data)->content_type, archive->priv->content_type ) )
+        {
 #ifdef DEBUG
-      g_debug("found template");
+            g_debug( "found template" );
 #endif
-      archive->priv->s_template = iter->data;
-      break;
+            archive->priv->s_template = iter->data;
+            break;
+        }
     }
-  }
 
-  if (NULL == archive->priv->s_template)
-  {
+    if ( NULL == archive->priv->s_template )
+    {
 #ifdef DEBUG
-    g_debug("not supported");
+        g_debug( "not supported" );
 #endif
-    g_object_unref(archive);
-    archive = NULL;
-  }
+        g_object_unref( archive );
+        archive = NULL;
+    }
 
-  return archive;
+    return archive;
 }
 
 /*
@@ -209,12 +198,12 @@ lsq_archive_new (GFile *file)
  *
  */
 guint
-lsq_archive_n_entry_properties(const LSQArchive *archive)
+lsq_archive_n_entry_properties ( const LSQArchive *archive )
 {
 #ifdef DEBUG
-	g_return_val_if_fail ( NULL != archive, 0 );
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), 0 );
 #endif
-	return lsq_support_template_get_n_properties(archive->priv->s_template) + LSQ_ARCHIVE_PROP_USER;
+    return lsq_support_template_get_n_properties( archive->priv->s_template ) + LSQ_ARCHIVE_PROP_USER;
 }
 
 /*
@@ -224,33 +213,39 @@ lsq_archive_n_entry_properties(const LSQArchive *archive)
  *
  */
 GType
-lsq_archive_get_entry_property_type(const LSQArchive *archive, guint n)
+lsq_archive_get_entry_property_type ( const LSQArchive *archive, guint n )
 {
-	switch(n)
-	{
-		case LSQ_ARCHIVE_PROP_FILENAME:
-		case LSQ_ARCHIVE_PROP_MIME_TYPE:
-			return G_TYPE_STRING;
-			break;
-		default:
-			return lsq_support_template_get_property_type(archive->priv->s_template, n - LSQ_ARCHIVE_PROP_USER);
-			break;
-	}
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), G_TYPE_NONE );
+    g_return_val_if_fail( lsq_archive_n_entry_properties( archive ) > n , G_TYPE_NONE );
+#endif
+    switch ( n )
+    {
+        case LSQ_ARCHIVE_PROP_FILENAME:
+        case LSQ_ARCHIVE_PROP_MIME_TYPE:
+            return G_TYPE_STRING;
+
+        default:
+            return lsq_support_template_get_property_type( archive->priv->s_template, n - LSQ_ARCHIVE_PROP_USER );
+    }
 }
 
 guint
-lsq_archive_get_entry_property_offset(const LSQArchive *archive, guint n)
+lsq_archive_get_entry_property_offset ( const LSQArchive *archive, guint n )
 {
-  switch(n)
-  {
-    case LSQ_ARCHIVE_PROP_FILENAME:
-    case LSQ_ARCHIVE_PROP_MIME_TYPE:
-      g_return_val_if_reached ( 0 );
-      break;
-    default:
-      return lsq_support_template_get_property_offset(archive->priv->s_template, n - LSQ_ARCHIVE_PROP_USER);
-      break;
-  }
+#ifdef DEBUG
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), 0 );
+    g_return_val_if_fail( lsq_archive_n_entry_properties( archive ) > n , 0 );
+#endif
+    switch ( n )
+    {
+        case LSQ_ARCHIVE_PROP_FILENAME:
+        case LSQ_ARCHIVE_PROP_MIME_TYPE:
+            g_return_val_if_reached( 0 );
+
+        default:
+            return lsq_support_template_get_property_offset( archive->priv->s_template, n - LSQ_ARCHIVE_PROP_USER );
+    }
 }
 
 /*
@@ -260,28 +255,31 @@ lsq_archive_get_entry_property_offset(const LSQArchive *archive, guint n)
  *
  */
 const gchar *
-lsq_archive_get_entry_property_name(const LSQArchive *archive, guint n)
+lsq_archive_get_entry_property_name ( const LSQArchive *archive, guint n )
 {
-	switch(n)
-	{
-		case LSQ_ARCHIVE_PROP_FILENAME:
-			return _("Name");
-		case LSQ_ARCHIVE_PROP_MIME_TYPE:
-			return _("Mime type");
-			break;
-		default:
-			return lsq_support_template_get_property_name(archive->priv->s_template, n - LSQ_ARCHIVE_PROP_USER);
-			break;
-	}
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+    g_return_val_if_fail( lsq_archive_n_entry_properties( archive ) > n , NULL );
+
+    switch( n )
+    {
+        case LSQ_ARCHIVE_PROP_FILENAME:
+            return _("Name");
+
+        case LSQ_ARCHIVE_PROP_MIME_TYPE:
+            return _("Mime type");
+
+        default:
+            return lsq_support_template_get_property_name( archive->priv->s_template, n - LSQ_ARCHIVE_PROP_USER );
+    }
 }
 
 guint
-lsq_archive_entry_properties_size(const LSQArchive *archive)
+lsq_archive_entry_properties_size ( const LSQArchive *archive )
 {
 #ifdef DEBUG
-  g_return_val_if_fail ( NULL != archive, 0 );
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), 0 );
 #endif
-  return lsq_support_template_get_properties_size(archive->priv->s_template);
+    return lsq_support_template_get_properties_size( archive->priv->s_template );
 }
 
 /*
@@ -291,9 +289,11 @@ lsq_archive_entry_properties_size(const LSQArchive *archive)
  * Return value: filename string
  */
 gchar *
-lsq_archive_get_filename (const LSQArchive *archive)
+lsq_archive_get_filename ( const LSQArchive *archive )
 {
-  return g_file_get_basename(archive->priv->file);
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+
+    return g_file_get_basename( archive->priv->file );
 }
 
 /*
@@ -303,91 +303,110 @@ lsq_archive_get_filename (const LSQArchive *archive)
  * Return value: filename string
  */
 gchar *
-lsq_archive_get_path (const LSQArchive *archive)
+lsq_archive_get_path ( const LSQArchive *archive )
 {
-  return g_file_get_path(archive->priv->file);
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+
+    return g_file_get_path( archive->priv->file );
 }
 
 GFile *
-lsq_archive_get_file (const LSQArchive *archive)
+lsq_archive_get_file ( const LSQArchive *archive )
 {
-	return archive->priv->file;
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+
+    return archive->priv->file;
 }
 
 void
-lsq_archive_refreshed(const LSQArchive *archive)
+lsq_archive_refreshed ( const LSQArchive *archive )
 {
-    g_debug("%s", __FUNCTION__);
-	g_signal_emit(G_OBJECT(archive), lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_REFRESHED], 0, NULL);
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+
+    g_signal_emit( G_OBJECT( archive ), lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_REFRESHED], 0, NULL );
 }
 
-void lsq_archive_add_children(GSList *files)
+void lsq_archive_add_children ( GSList *files )
 {
-	GSList *iter;
-	for ( iter = files; NULL != iter; iter = iter->next )
-	{
-		unsigned int i, size = lsq_archive_iter_n_children(iter->data);
-		for ( i = 0; i < size; ++i )
-		{
-			files = g_slist_append(iter, lsq_archive_iter_nth_child(iter->data, i));
-		}
-	}
+    GSList *iter;
+    for ( iter = files; NULL != iter; iter = iter->next )
+    {
+        unsigned int i, size = lsq_archive_iter_n_children( iter->data );
+        for ( i = 0; i < size; ++i )
+        {
+            files = g_slist_append( iter, lsq_archive_iter_nth_child( iter->data, i ) );
+        }
+    }
 }
 
 void
-lsq_archive_state_changed(const LSQArchive *archive)
+lsq_archive_state_changed ( const LSQArchive *archive )
 {
-	g_signal_emit(G_OBJECT(archive), lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_STATE_CHANGED], 0, NULL);
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+
+    g_signal_emit( G_OBJECT( archive ), lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_STATE_CHANGED], 0, NULL );
 }
 
 void
-lsq_close_archive(LSQArchive *archive)
+lsq_close_archive ( LSQArchive *archive )
 {
-	lsq_opened_archive_list = g_slist_remove(lsq_opened_archive_list, archive);
+    g_return_if_fail( LSQ_IS_ARCHIVE( archive ) );
+
+    lsq_opened_archive_list = g_slist_remove( lsq_opened_archive_list, archive );
 
-	if ( NULL != archive->priv->file )
+    if ( NULL != archive->priv->file )
     {
-		g_object_unref (archive->priv->file);
+        g_object_unref( archive->priv->file );
         archive->priv->file = NULL;
     }
-	if ( NULL != archive->priv->content_type )
+    if ( NULL != archive->priv->content_type )
     {
-		g_free (archive->priv->content_type);
+        g_free( archive->priv->content_type );
         archive->priv->content_type = NULL;
     }
 
-	lsq_archive_stop(archive);
-	g_object_unref(archive);
+    lsq_archive_stop( archive );
+    g_object_unref( archive );
 }
 
 gboolean
-lsq_archive_can_stop(const LSQArchive *archive)
+lsq_archive_can_stop ( const LSQArchive *archive )
 {
-	return FALSE;
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), FALSE );
+
+    return FALSE;
 }
 
 gboolean
-lsq_archive_stop(const LSQArchive *archive)
+lsq_archive_stop ( const LSQArchive *archive )
 {
-	return FALSE;
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), FALSE );
+
+    return FALSE;
 }
 
 const gchar *
-lsq_archive_get_state_msg(const LSQArchive *archive)
+lsq_archive_get_state_msg ( const LSQArchive *archive )
 {
-	return archive->priv->state_msg;
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+
+    return archive->priv->state_msg;
 }
 
 LSQArchiveState
-lsq_archive_get_state(const LSQArchive *archive)
+lsq_archive_get_state ( const LSQArchive *archive )
 {
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), LSQ_ARCHIVE_STATE_IDLE );
+
     return archive->priv->state;
 }
 
 LSQSupportType
-lsq_archive_get_support_mask(const LSQArchive *archive)
+lsq_archive_get_support_mask ( const LSQArchive *archive )
 {
-	return archive->priv->s_template->support_mask;
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), 0 );
+
+    return archive->priv->s_template->support_mask;
 }
 
 /**
@@ -398,53 +417,69 @@ lsq_archive_get_support_mask(const LSQArchive *archive)
  * Return value: TRUE on success
  */
 gboolean
-lsq_archive_operate(LSQArchive *archive, LSQCommandType type, const gchar **files, const gchar *directory)
+lsq_archive_operate ( LSQArchive *archive, LSQCommandType type, gchar **files, const gchar *directory )
 {
     LSQSupportTemplate *s_template;
+    LSQExecuteContext *leaked = NULL; /* FIXME */
 
-    g_return_val_if_fail ( NULL != archive, FALSE );
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), FALSE );
 
     s_template = archive->priv->s_template;
 
-    switch (type)
+    switch ( type )
     {
         case LSQ_COMMAND_TYPE_ADD:
-            lsq_command_queue_execute(s_template->add_cmd_queue, archive, files, NULL, NULL);
+            g_return_val_if_fail( files, FALSE );
+            leaked = lsq_command_queue_execute( s_template->add_cmd_queue, archive, files, NULL, NULL );
             break;
+
         case LSQ_COMMAND_TYPE_REMOVE:
-            lsq_command_queue_execute(s_template->remove_cmd_queue, archive, files, NULL, NULL);
+            g_return_val_if_fail( files, FALSE );
+            leaked = lsq_command_queue_execute( s_template->remove_cmd_queue, archive, files, NULL, NULL );
             break;
+
         case LSQ_COMMAND_TYPE_EXTRACT:
-            lsq_command_queue_execute(s_template->extract_cmd_queue, archive, files, directory, NULL);
+            g_return_val_if_fail( directory, FALSE );
+            leaked = lsq_command_queue_execute( s_template->extract_cmd_queue, archive, files, directory, NULL );
             break;
+
         case LSQ_COMMAND_TYPE_REFRESH:
-            lsq_command_queue_execute(s_template->refresh_cmd_queue, archive, files, NULL, s_template->parser);
+            leaked = lsq_command_queue_execute( s_template->refresh_cmd_queue, archive, NULL, NULL, s_template->parser );
             break;
+
         default:
-            return FALSE;
-            break;
+            g_return_val_if_reached( FALSE );
     }
+
+    (void)leaked;
+
     return TRUE;
 }
 
 LSQCommandOptionPair **
-lsq_archive_get_command_options(LSQArchive *archive, LSQCommandType type)
+lsq_archive_get_command_options ( LSQArchive *archive, LSQCommandType type )
 {
     LSQCommandOptionPair **option_list = NULL;
+    LSQSupportTemplate *s_template;
+
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
 
-    LSQSupportTemplate *s_template = archive->priv->s_template;
+    s_template = archive->priv->s_template;
 
-    switch (type)
+    switch ( type )
     {
         case LSQ_COMMAND_TYPE_ADD:
-            option_list = lsq_command_option_create_pair(s_template->add_options);
+            option_list = lsq_command_option_create_pair( s_template->add_options );
             break;
+
         case LSQ_COMMAND_TYPE_REMOVE:
-            option_list = lsq_command_option_create_pair(s_template->remove_options);
+            option_list = lsq_command_option_create_pair( s_template->remove_options );
             break;
+
         case LSQ_COMMAND_TYPE_EXTRACT:
-            option_list = lsq_command_option_create_pair(s_template->extract_options);
+            option_list = lsq_command_option_create_pair( s_template->extract_options );
             break;
+
         default:
             break;
     }
diff --git a/libsqueeze/archive.h b/libsqueeze/archive.h
index e129227..2c2f4f5 100644
--- a/libsqueeze/archive.h
+++ b/libsqueeze/archive.h
@@ -19,29 +19,29 @@ G_BEGIN_DECLS
 
 #define LSQ_TYPE_ARCHIVE lsq_archive_get_type()
 
-#define LSQ_ARCHIVE(obj)		 ( \
-		G_TYPE_CHECK_INSTANCE_CAST ((obj),	\
-			LSQ_TYPE_ARCHIVE,	  \
-			LSQArchive))
+#define LSQ_ARCHIVE(obj) ( \
+        G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+            LSQ_TYPE_ARCHIVE, \
+            LSQArchive))
 
-#define LSQ_IS_ARCHIVE(obj)	  ( \
-		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
-			LSQ_TYPE_ARCHIVE))
+#define LSQ_IS_ARCHIVE(obj) ( \
+        G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+            LSQ_TYPE_ARCHIVE))
 
-#define LSQ_ARCHIVE_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
-			LSQ_TYPE_ARCHIVE,	  \
-			LSQArchiveClass))
+#define LSQ_ARCHIVE_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_CAST ((klass), \
+            LSQ_TYPE_ARCHIVE, \
+            LSQArchiveClass))
 
-#define LSQ_IS_ARCHIVE_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
-			LSQ_TYPE_ARCHIVE))
+#define LSQ_IS_ARCHIVE_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_TYPE ((klass), \
+            LSQ_TYPE_ARCHIVE))
 
 enum
 {
-	LSQ_ARCHIVE_PROP_FILENAME = 0,
-	LSQ_ARCHIVE_PROP_MIME_TYPE,
-	LSQ_ARCHIVE_PROP_USER
+    LSQ_ARCHIVE_PROP_FILENAME = 0,
+    LSQ_ARCHIVE_PROP_MIME_TYPE,
+    LSQ_ARCHIVE_PROP_USER
 };
 
 typedef enum
@@ -57,7 +57,7 @@ struct _LSQArchivePrivate
     GFile *file;
     gchar *content_type;
 
-	LSQSupportTemplate *s_template;
+    LSQSupportTemplate *s_template;
 
     LSQArchiveState state;
     const gchar *state_msg;
@@ -68,18 +68,18 @@ typedef struct _LSQArchive LSQArchive;
 
 struct _LSQArchive
 {
-	GObject parent;
-	LSQArchivePrivate  *priv;
-	LSQArchiveEntry	*root_entry;
-	LSQArchiveIterPool *pool;
-	gchar *temp_dir;
-	GSList *monitor_list;
-	struct {
-		guint64 archive_size;
-		guint64 content_size;
-		guint64 n_files;
-		guint64 n_directories;
-	} props;
+    GObject parent;
+    LSQArchivePrivate  *priv;
+    LSQArchiveEntry *root_entry;
+    LSQArchiveIterPool *pool;
+    gchar *temp_dir;
+    GSList *monitor_list;
+    struct {
+        guint64 archive_size;
+        guint64 content_size;
+        guint64 n_files;
+        guint64 n_directories;
+    } props;
 };
 
 
@@ -87,39 +87,62 @@ typedef struct _LSQArchiveClass LSQArchiveClass;
 
 struct _LSQArchiveClass
 {
-	GObjectClass parent;
+    GObjectClass parent;
 };
 
 
-GType		   lsq_archive_get_type(void);
+GType
+lsq_archive_get_type ( void ) G_GNUC_CONST;
 
-gchar		*lsq_archive_get_filename(const LSQArchive *archive);
-gchar		*lsq_archive_get_path(const LSQArchive *archive);
-const gchar	*lsq_archive_get_mimetype(const LSQArchive *archive);
-gboolean		lsq_archive_exists(const LSQArchive *archive);
-LSQSupportType  lsq_archive_get_support_mask(const LSQArchive *archive);
+gchar *
+lsq_archive_get_filename ( const LSQArchive *archive ) G_GNUC_WARN_UNUSED_RESULT;
+gchar *
+lsq_archive_get_path ( const LSQArchive *archive ) G_GNUC_WARN_UNUSED_RESULT;
+const gchar *
+lsq_archive_get_mimetype ( const LSQArchive *archive );
+gboolean
+lsq_archive_exists ( const LSQArchive *archive );
+LSQSupportType
+lsq_archive_get_support_mask ( const LSQArchive *archive );
 
 
-LSQArchive		 *lsq_archive_new(GFile *) G_GNUC_INTERNAL;
-void				lsq_archive_state_changed(const LSQArchive *archive) G_GNUC_INTERNAL;
-void				lsq_archive_add_children(GSList *files);
-gboolean			lsq_archive_remove_file(LSQArchive *, const gchar *);
-
-GFile *lsq_archive_get_file(const LSQArchive *);
-
-gboolean		lsq_archive_operate(LSQArchive *archive, LSQCommandType type, const gchar **, const gchar *);
+LSQArchive *
+lsq_archive_new ( GFile * ) G_GNUC_WARN_UNUSED_RESULT;
+void
+lsq_archive_state_changed ( const LSQArchive *archive );
+void
+lsq_archive_add_children ( GSList *files );
+gboolean
+lsq_archive_remove_file (
+        LSQArchive *,
+        const gchar *
+    );
+
+GFile *
+lsq_archive_get_file ( const LSQArchive * );
+
+gboolean
+lsq_archive_operate (
+        LSQArchive *archive,
+        LSQCommandType type,
+        gchar **,
+        const gchar *
+    );
 
 LSQCommandOptionPair **
-lsq_archive_get_command_options(LSQArchive *archive, LSQCommandType type);
+lsq_archive_get_command_options (
+        LSQArchive *archive,
+        LSQCommandType type
+    ) G_GNUC_WARN_UNUSED_RESULT;
 
-const gchar	*
-lsq_archive_get_state_msg(const LSQArchive *archive);
+const gchar *
+lsq_archive_get_state_msg ( const LSQArchive *archive );
 
 LSQArchiveState
-lsq_archive_get_state(const LSQArchive *archive);
+lsq_archive_get_state ( const LSQArchive *archive );
 
 void
-lsq_archive_refreshed(const LSQArchive *archive);
+lsq_archive_refreshed ( const LSQArchive *archive );
 
 
 G_END_DECLS
diff --git a/libsqueeze/btree.c b/libsqueeze/btree.c
index 5d98f0e..1ac87b8 100644
--- a/libsqueeze/btree.c
+++ b/libsqueeze/btree.c
@@ -35,7 +35,8 @@ LSQBTree *
 lsq_btree_insert_sorted_single (
         LSQBTree *list,
         LSQArchiveEntry *entry,
-        GCompareFunc cmp_func )
+        GCompareFunc cmp_func
+    )
 {
     gint cmp;
     LSQBTree *iter;
@@ -48,10 +49,15 @@ lsq_btree_insert_sorted_single (
     gint swap_balance;
     gboolean short_side;
 
+#if DEBUG
+    g_return_val_if_fail( NULL != entry, NULL );
+    g_return_val_if_fail( NULL != cmp_func, NULL );
+#endif
+
     /* Check for a flat list */
-    if ( NULL != list && NULL != list->next )
+    if ( G_UNLIKELY ( NULL != list && NULL != list->next ) )
     {
-        g_critical("Cannot insert into a flattened tree");
+        g_error( "Cannot insert into a flattened tree" );
         return NULL;
     }
 
@@ -74,17 +80,17 @@ lsq_btree_insert_sorted_single (
         else
         {
             /* Logic outside this routine dictates we should never find a match */
-            g_critical("THIS SHOULD NOT HAPPEN!!! (the universe has just collapsed)");
+            g_error( "THIS SHOULD NOT HAPPEN!!! (the universe has just collapsed)" );
             return NULL;
         }
 
         /* Keep a stack of the path we followed */
-        g_return_val_if_fail(stack_i < LSQ_BTREE_MAX_DEPTH, NULL);
+        g_return_val_if_fail( LSQ_BTREE_MAX_DEPTH > stack_i, NULL );
         stack[stack_i++] = iter;
     }
 
     /* Create a new tree element */
-    new_entry = g_new0(LSQBTree, 1);
+    new_entry = g_new0( LSQBTree, 1 );
     new_entry->entry = entry;
 
     /* Check it this is a new tree */
@@ -257,6 +263,11 @@ lsq_btree_remove_sorted_single (
     gint swap_balance;
 #endif
 
+#if DEBUG
+    g_return_val_if_fail( NULL != filename, NULL );
+    g_return_val_if_fail( NULL != cmp_func, NULL );
+#endif
+
     if ( NULL != found )
     {
         *found = NULL;
@@ -317,7 +328,7 @@ lsq_btree_remove_sorted_single (
             }
 
             /* Keep a stack of the path we followed */
-            g_return_val_if_fail(stack_i < LSQ_BTREE_MAX_DEPTH, NULL);
+            g_return_val_if_fail( LSQ_BTREE_MAX_DEPTH > stack_i, NULL );
             stack[stack_i++] = iter;
         }
 
@@ -345,7 +356,7 @@ lsq_btree_remove_sorted_single (
              * We that the longest of the two paths, i the hope to be better balanced. */
             
             /* Keep a stack of the path we followed */
-            g_return_val_if_fail(stack_i < LSQ_BTREE_MAX_DEPTH, NULL);
+            g_return_val_if_fail( LSQ_BTREE_MAX_DEPTH > stack_i, NULL );
             stack[stack_i++] = iter;
 
             /* Right it the longest */
@@ -357,7 +368,7 @@ lsq_btree_remove_sorted_single (
                     next = &swap_iter->left;
 
                     /* Keep a stack of the path we followed */
-                    g_return_val_if_fail(stack_i < LSQ_BTREE_MAX_DEPTH, NULL);
+                    g_return_val_if_fail( LSQ_BTREE_MAX_DEPTH > stack_i, NULL );
                     stack[stack_i++] = iter;
                 }
 
@@ -377,7 +388,7 @@ lsq_btree_remove_sorted_single (
                     next = &swap_iter->right;
 
                     /* Keep a stack of the path we followed */
-                    g_return_val_if_fail(stack_i < LSQ_BTREE_MAX_DEPTH, NULL);
+                    g_return_val_if_fail( LSQ_BTREE_MAX_DEPTH > stack_i, NULL );
                     stack[stack_i++] = iter;
                 }
 
@@ -563,7 +574,7 @@ lsq_btree_length ( LSQBTree *list )
             for ( iter = list; NULL != iter; iter = iter->left )
             {
                 stack[stack_i++] = iter;
-		g_return_val_if_fail(stack_i < LSQ_BTREE_MAX_DEPTH, 0);
+                g_return_val_if_fail( LSQ_BTREE_MAX_DEPTH > stack_i, 0 );
 
                 size++;
             }
@@ -599,7 +610,7 @@ lsq_btree_free ( LSQBTree *list )
             for ( iter = list; NULL != iter; iter = iter->left )
             {
                 stack[stack_i++] = iter;
-		g_return_if_fail(stack_i < LSQ_BTREE_MAX_DEPTH);
+		g_return_if_fail( LSQ_BTREE_MAX_DEPTH > stack_i );
             }
 
             list = stack[--stack_i]->right;
@@ -629,7 +640,7 @@ lsq_btree_flatten ( LSQBTree *list )
         for ( iter = next; NULL != iter; iter = iter->left )
         {
             stack[stack_i++] = iter;
-	    g_return_val_if_fail(stack_i < LSQ_BTREE_MAX_DEPTH, NULL);
+            g_return_val_if_fail( LSQ_BTREE_MAX_DEPTH > stack_i, NULL );
         }
 
         next = stack[--stack_i];
diff --git a/libsqueeze/btree.h b/libsqueeze/btree.h
index 574a87b..d9abb01 100644
--- a/libsqueeze/btree.h
+++ b/libsqueeze/btree.h
@@ -31,22 +31,24 @@ LSQBTree *
 lsq_btree_insert_sorted_single (
         LSQBTree *list,
         LSQArchiveEntry *entry,
-        GCompareFunc ) G_GNUC_INTERNAL;
+        GCompareFunc
+    ) G_GNUC_WARN_UNUSED_RESULT G_GNUC_INTERNAL;
 
 LSQBTree *
 lsq_btree_remove_sorted_single (
         LSQBTree *list,
         gchar *filename,
         GCompareFunc cmp_func,
-        LSQArchiveEntry **found ) G_GNUC_INTERNAL;
+        LSQArchiveEntry **found
+    ) G_GNUC_WARN_UNUSED_RESULT G_GNUC_INTERNAL;
 
 guint
-lsq_btree_length ( LSQBTree *list ) G_GNUC_INTERNAL;
+lsq_btree_length ( LSQBTree *list ) G_GNUC_PURE G_GNUC_INTERNAL;
 
 void
 lsq_btree_free ( LSQBTree *list ) G_GNUC_INTERNAL;
 
 LSQBTree *
-lsq_btree_flatten ( LSQBTree *list ) G_GNUC_INTERNAL;
+lsq_btree_flatten ( LSQBTree *list ) G_GNUC_WARN_UNUSED_RESULT G_GNUC_INTERNAL;
 
 #endif /* __LSQ_BTREE_H__ */
diff --git a/libsqueeze/command-option.c b/libsqueeze/command-option.c
index c1e7e19..8983d95 100644
--- a/libsqueeze/command-option.c
+++ b/libsqueeze/command-option.c
@@ -22,287 +22,329 @@
 
 #include "command-option.h"
 
-#define LSQ_COMMAND_OPTION_GET_CLASS(obj) (	\
-		G_TYPE_INSTANCE_GET_CLASS ((obj),  \
-			LSQ_TYPE_COMMAND_OPTION,				 \
-	  LSQCommandOptionClass))
+#define LSQ_COMMAND_OPTION_GET_CLASS(obj) ( \
+        G_TYPE_INSTANCE_GET_CLASS ((obj),   \
+            LSQ_TYPE_COMMAND_OPTION,        \
+            LSQCommandOptionClass))
 
-typedef void (*LSQCommandOptionGetDefaultFunc)(const LSQCommandOption*, GValue*);
+typedef void (*LSQCommandOptionGetDefaultFunc) ( const LSQCommandOption *, GValue * );
 
 typedef struct _LSQCommandOptionClass LSQCommandOptionClass;
 
 struct _LSQCommandOptionClass
 {
-  GTypeClass parent;
+    GTypeClass parent;
 
-  LSQCommandOptionGetDefaultFunc get_default;
+    LSQCommandOptionGetDefaultFunc get_default;
 };
 
-static void lsq_command_option_class_init(LSQCommandOptionClass *);
-static void lsq_command_option_bool_class_init(LSQCommandOptionClass *);
-static void lsq_command_option_string_class_init(LSQCommandOptionClass *);
-static void lsq_command_option_int_class_init(LSQCommandOptionClass *);
-static void lsq_command_option_uint_class_init(LSQCommandOptionClass *);
+static void
+lsq_command_option_class_init ( LSQCommandOptionClass * );
+static void
+lsq_command_option_bool_class_init ( LSQCommandOptionClass * );
+static void
+lsq_command_option_string_class_init ( LSQCommandOptionClass * );
+static void
+lsq_command_option_int_class_init ( LSQCommandOptionClass * );
+static void
+lsq_command_option_uint_class_init ( LSQCommandOptionClass * );
 
 GType
-lsq_command_option_get_type(gint type_idx)
+lsq_command_option_get_type ( guint type_idx )
 {
-	static GType lsq_command_option_type[5] = {0};
+    static GType lsq_command_option_type[5] = { G_TYPE_INVALID };
 
- 	if ( G_TYPE_INVALID == lsq_command_option_type[0] )
-	{
- 		static const GTypeFundamentalInfo lsq_command_option_fund = 
-    {
-      G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE
-    };
- 		static const GTypeInfo lsq_command_option[5] = 
+    g_return_val_if_fail( 5 > type_idx, G_TYPE_INVALID );
+
+    if ( G_TYPE_INVALID == lsq_command_option_type[0] )
     {
-      {
-        sizeof (LSQCommandOptionClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) lsq_command_option_class_init,
-        (GClassFinalizeFunc) NULL,
-        NULL,
-        sizeof (LSQCommandOption),
-        0,
-        (GInstanceInitFunc) NULL,
-        NULL
-      },
-      {
-        sizeof (LSQCommandOptionClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) lsq_command_option_bool_class_init,
-        (GClassFinalizeFunc) NULL,
-        NULL,
-        sizeof (LSQCommandOptionBool),
-        0,
-        (GInstanceInitFunc) NULL,
-        NULL
-      },
-      {
-        sizeof (LSQCommandOptionClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) lsq_command_option_string_class_init,
-        (GClassFinalizeFunc) NULL,
-        NULL,
-        sizeof (LSQCommandOptionString),
-        0,
-        (GInstanceInitFunc) NULL,
-        NULL
-      },
-      {
-        sizeof (LSQCommandOptionClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) lsq_command_option_int_class_init,
-        (GClassFinalizeFunc) NULL,
-        NULL,
-        sizeof (LSQCommandOptionInt),
-        0,
-        (GInstanceInitFunc) NULL,
-        NULL
-      },
-      {
-        sizeof (LSQCommandOptionClass),
-        (GBaseInitFunc) NULL,
-        (GBaseFinalizeFunc) NULL,
-        (GClassInitFunc) lsq_command_option_uint_class_init,
-        (GClassFinalizeFunc) NULL,
-        NULL,
-        sizeof (LSQCommandOptionUint),
-        0,
-        (GInstanceInitFunc) NULL,
-        NULL
-      }
-    };
-
-		lsq_command_option_type[0] = g_type_register_fundamental(g_type_fundamental_next(), "LSQCommandOption", &lsq_command_option[0], &lsq_command_option_fund, 0);
-		lsq_command_option_type[1] = g_type_register_static (lsq_command_option_type[0], "LSQCommandOptionBool", &lsq_command_option[1], 0);
-		lsq_command_option_type[2] = g_type_register_static (lsq_command_option_type[0], "LSQCommandOptionString", &lsq_command_option[2], 0);
-		lsq_command_option_type[3] = g_type_register_static (lsq_command_option_type[0], "LSQCommandOptionInt", &lsq_command_option[3], 0);
-		lsq_command_option_type[4] = g_type_register_static (lsq_command_option_type[0], "LSQCommandOptionUint", &lsq_command_option[4], 0);
-	}
-	return lsq_command_option_type[type_idx];
+        static const GTypeFundamentalInfo lsq_command_option_fund = 
+        {
+            G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE
+        };
+        static const GTypeInfo lsq_command_option[5] = 
+        {
+            {
+                sizeof (LSQCommandOptionClass),
+                (GBaseInitFunc) NULL,
+                (GBaseFinalizeFunc) NULL,
+                (GClassInitFunc) lsq_command_option_class_init,
+                (GClassFinalizeFunc) NULL,
+                NULL,
+                sizeof (LSQCommandOption),
+                0,
+                (GInstanceInitFunc) NULL,
+                NULL
+            },
+            {
+                sizeof (LSQCommandOptionClass),
+                (GBaseInitFunc) NULL,
+                (GBaseFinalizeFunc) NULL,
+                (GClassInitFunc) lsq_command_option_bool_class_init,
+                (GClassFinalizeFunc) NULL,
+                NULL,
+                sizeof (LSQCommandOptionBool),
+                0,
+                (GInstanceInitFunc) NULL,
+                NULL
+            },
+            {
+                sizeof (LSQCommandOptionClass),
+                (GBaseInitFunc) NULL,
+                (GBaseFinalizeFunc) NULL,
+                (GClassInitFunc) lsq_command_option_string_class_init,
+                (GClassFinalizeFunc) NULL,
+                NULL,
+                sizeof (LSQCommandOptionString),
+                0,
+                (GInstanceInitFunc) NULL,
+                NULL
+            },
+            {
+                sizeof (LSQCommandOptionClass),
+                (GBaseInitFunc) NULL,
+                (GBaseFinalizeFunc) NULL,
+                (GClassInitFunc) lsq_command_option_int_class_init,
+                (GClassFinalizeFunc) NULL,
+                NULL,
+                sizeof (LSQCommandOptionInt),
+                0,
+                (GInstanceInitFunc) NULL,
+                NULL
+            },
+            {
+                sizeof (LSQCommandOptionClass),
+                (GBaseInitFunc) NULL,
+                (GBaseFinalizeFunc) NULL,
+                (GClassInitFunc) lsq_command_option_uint_class_init,
+                (GClassFinalizeFunc) NULL,
+                NULL,
+                sizeof (LSQCommandOptionUint),
+                0,
+                (GInstanceInitFunc) NULL,
+                NULL
+            }
+        };
+
+        lsq_command_option_type[0] = g_type_register_fundamental ( g_type_fundamental_next(), "LSQCommandOption", &lsq_command_option[0], &lsq_command_option_fund, 0 );
+        lsq_command_option_type[1] = g_type_register_static( lsq_command_option_type[0], "LSQCommandOptionBool", &lsq_command_option[1], 0 );
+        lsq_command_option_type[2] = g_type_register_static( lsq_command_option_type[0], "LSQCommandOptionString", &lsq_command_option[2], 0 );
+        lsq_command_option_type[3] = g_type_register_static( lsq_command_option_type[0], "LSQCommandOptionInt", &lsq_command_option[3], 0 );
+        lsq_command_option_type[4] = g_type_register_static( lsq_command_option_type[0], "LSQCommandOptionUint", &lsq_command_option[4], 0 );
+    }
+    return lsq_command_option_type[type_idx];
 }
 
 LSQCommandOption **
-lsq_command_option_create_list(XfceRc *rc, gchar **option_names)
+lsq_command_option_create_list ( XfceRc *rc, gchar **option_names )
 {
-  LSQCommandOption **command_options = g_new0(LSQCommandOption*, g_strv_length(option_names));
-  LSQCommandOption **cmd_opt_iter = command_options;
-  gchar **option_iter;
-  for(option_iter = option_names; *option_iter; option_iter++)
-  {
-    const gchar *type;
-    gchar *option_group = g_strconcat("Squeeze-Option-", *option_iter, NULL);
-    xfce_rc_set_group(rc, option_group);
-
-    type = xfce_rc_read_entry(rc, "X-Squeeze-Type", "");
-    if ( 0 == g_ascii_strcasecmp("Bool", type) )
-    {
-      *cmd_opt_iter = LSQ_COMMAND_OPTION(g_type_create_instance(LSQ_TYPE_COMMAND_OPTION_BOOL));
-      (*cmd_opt_iter)->value_type = G_TYPE_BOOLEAN;
-      LSQ_COMMAND_OPTION_BOOL(*cmd_opt_iter)->default_value = xfce_rc_read_bool_entry(rc, "X-Squeeze-Value", FALSE);
-    }
-    else if ( 0 == g_ascii_strcasecmp("String", type) )
-    {
-      *cmd_opt_iter = LSQ_COMMAND_OPTION(g_type_create_instance(LSQ_TYPE_COMMAND_OPTION_STRING));
-      (*cmd_opt_iter)->value_type = G_TYPE_STRING;
-      LSQ_COMMAND_OPTION_STRING(*cmd_opt_iter)->default_value = xfce_rc_read_entry(rc, "X-Squeeze-Value", NULL);
-      LSQ_COMMAND_OPTION_STRING(*cmd_opt_iter)->filter = xfce_rc_read_entry(rc, "X-Squeeze-Filter", NULL);
-    }
-    else if ( 0 == g_ascii_strcasecmp("Int", type) )
-    {
-      *cmd_opt_iter = LSQ_COMMAND_OPTION(g_type_create_instance(LSQ_TYPE_COMMAND_OPTION_INT));
-      (*cmd_opt_iter)->value_type = G_TYPE_INT;
-      LSQ_COMMAND_OPTION_INT(*cmd_opt_iter)->default_value = xfce_rc_read_int_entry(rc, "X-Squeeze-Value", 0);
-      LSQ_COMMAND_OPTION_INT(*cmd_opt_iter)->min_value = xfce_rc_read_int_entry(rc, "X-Squeeze-Min", 0);
-      LSQ_COMMAND_OPTION_INT(*cmd_opt_iter)->max_value = xfce_rc_read_int_entry(rc, "X-Squeeze-Max", 0);
-    }
-    else if ( 0 == g_ascii_strcasecmp("Uint", type) )
-    {
-      *cmd_opt_iter = LSQ_COMMAND_OPTION(g_type_create_instance(LSQ_TYPE_COMMAND_OPTION_UINT));
-      (*cmd_opt_iter)->value_type = G_TYPE_UINT;
-      LSQ_COMMAND_OPTION_UINT(*cmd_opt_iter)->default_value = xfce_rc_read_int_entry(rc, "X-Squeeze-Value", 0);
-      LSQ_COMMAND_OPTION_UINT(*cmd_opt_iter)->min_value = xfce_rc_read_int_entry(rc, "X-Squeeze-Min", 0);
-      LSQ_COMMAND_OPTION_UINT(*cmd_opt_iter)->max_value = xfce_rc_read_int_entry(rc, "X-Squeeze-Max", 0);
-    }
-    else
-    {
-      continue;
-    }
+    LSQCommandOption **command_options;
+    LSQCommandOption **cmd_opt_iter;
+    gchar **option_iter;
 
-    (*cmd_opt_iter)->name = g_strdup(*option_iter);
-    (*cmd_opt_iter)->flag = xfce_rc_read_entry(rc, "X-Squeeze-Flag", NULL);
-    (*cmd_opt_iter)->blurb = xfce_rc_read_entry(rc, "X-Squeeze-Description", NULL);
+    g_return_val_if_fail( NULL != rc, NULL);
+    g_return_val_if_fail( NULL != option_names, NULL);
 
-    cmd_opt_iter++;
-  }
+    command_options = g_new0( LSQCommandOption *, g_strv_length( option_names ) );
+    cmd_opt_iter = command_options;
 
-  return command_options;
+    for ( option_iter = option_names; NULL != *option_iter; ++option_iter )
+    {
+        const gchar *type;
+        gchar *option_group = g_strconcat( "Squeeze-Option-", *option_iter, NULL );
+        xfce_rc_set_group( rc, option_group );
+
+        type = xfce_rc_read_entry( rc, "X-Squeeze-Type", "" );
+        if ( 0 == g_ascii_strcasecmp( "Bool", type ) )
+        {
+            *cmd_opt_iter = LSQ_COMMAND_OPTION( g_type_create_instance( LSQ_TYPE_COMMAND_OPTION_BOOL ) );
+            (*cmd_opt_iter)->value_type = G_TYPE_BOOLEAN;
+            LSQ_COMMAND_OPTION_BOOL( *cmd_opt_iter )->default_value = xfce_rc_read_bool_entry( rc, "X-Squeeze-Value", FALSE );
+        }
+        else if ( 0 == g_ascii_strcasecmp( "String", type ) )
+        {
+            *cmd_opt_iter = LSQ_COMMAND_OPTION( g_type_create_instance(LSQ_TYPE_COMMAND_OPTION_STRING ) );
+            (*cmd_opt_iter)->value_type = G_TYPE_STRING;
+            LSQ_COMMAND_OPTION_STRING( *cmd_opt_iter )->default_value = xfce_rc_read_entry(rc, "X-Squeeze-Value", NULL );
+            LSQ_COMMAND_OPTION_STRING( *cmd_opt_iter )->filter = xfce_rc_read_entry(rc, "X-Squeeze-Filter", NULL );
+        }
+        else if ( 0 == g_ascii_strcasecmp( "Int", type ) )
+        {
+            *cmd_opt_iter = LSQ_COMMAND_OPTION( g_type_create_instance( LSQ_TYPE_COMMAND_OPTION_INT ) );
+            (*cmd_opt_iter)->value_type = G_TYPE_INT;
+            LSQ_COMMAND_OPTION_INT( *cmd_opt_iter )->default_value = xfce_rc_read_int_entry( rc, "X-Squeeze-Value", 0 );
+            LSQ_COMMAND_OPTION_INT( *cmd_opt_iter )->min_value = xfce_rc_read_int_entry( rc, "X-Squeeze-Min", 0 );
+            LSQ_COMMAND_OPTION_INT( *cmd_opt_iter )->max_value = xfce_rc_read_int_entry( rc, "X-Squeeze-Max", 0 );
+        }
+        else if ( 0 == g_ascii_strcasecmp( "Uint", type ) )
+        {
+            *cmd_opt_iter = LSQ_COMMAND_OPTION( g_type_create_instance( LSQ_TYPE_COMMAND_OPTION_UINT ) );
+            (*cmd_opt_iter)->value_type = G_TYPE_UINT;
+            LSQ_COMMAND_OPTION_UINT( *cmd_opt_iter )->default_value = xfce_rc_read_int_entry( rc, "X-Squeeze-Value", 0 );
+            LSQ_COMMAND_OPTION_UINT( *cmd_opt_iter )->min_value = xfce_rc_read_int_entry( rc, "X-Squeeze-Min", 0 );
+            LSQ_COMMAND_OPTION_UINT( *cmd_opt_iter )->max_value = xfce_rc_read_int_entry( rc, "X-Squeeze-Max", 0 );
+        }
+        else
+        {
+            continue;
+        }
+
+        (*cmd_opt_iter)->name = g_strdup( *option_iter );
+        (*cmd_opt_iter)->flag = xfce_rc_read_entry( rc, "X-Squeeze-Flag", NULL );
+        (*cmd_opt_iter)->blurb = xfce_rc_read_entry( rc, "X-Squeeze-Description", NULL );
+
+        ++cmd_opt_iter;
+    }
+
+    return command_options;
 }
 
 LSQCommandOptionPair **
-lsq_command_option_create_pair(LSQCommandOption **option_list)
+lsq_command_option_create_pair ( LSQCommandOption **option_list )
 {
-  int length = 0;
-  LSQCommandOption **option_iter;
-  LSQCommandOptionPair **option_pair;
-  LSQCommandOptionPair **pair_iter;
-
-  g_return_val_if_fail ( NULL != option_list, NULL);
+    int length = 0;
+    LSQCommandOption **option_iter;
+    LSQCommandOptionPair **option_pair;
+    LSQCommandOptionPair **pair_iter;
 
+    if ( NULL == option_list )
+    {
+        return NULL;
+    }
 
-  for ( option_iter = option_list; NULL != *option_iter; option_iter++ )
-  {
-    length++;
-  }
+    for ( option_iter = option_list; NULL != *option_iter; ++option_iter )
+    {
+        ++length;
+    }
 
-  option_pair = g_new0(LSQCommandOptionPair*, length);
-  pair_iter = option_pair;
+    option_pair = g_new0( LSQCommandOptionPair *, length );
+    pair_iter = option_pair;
 
-  for ( option_iter = option_list; NULL != *option_iter; option_iter++ )
-  {
-    LSQCommandOption *option = *option_iter;
+    for ( option_iter = option_list; NULL != *option_iter; ++option_iter )
+    {
+        LSQCommandOption *option = *option_iter;
 
-    *pair_iter = g_new0(LSQCommandOptionPair, 1);
+        *pair_iter = g_new0( LSQCommandOptionPair, 1 );
 
-    (*pair_iter)->option = option;
-    g_value_init(&(*pair_iter)->value, option->value_type);
-    lsq_command_option_get_default(option, &(*pair_iter)->value);
+        (*pair_iter)->option = option;
+        g_value_init( &(*pair_iter)->value, option->value_type );
+        lsq_command_option_get_default( option, &(*pair_iter)->value );
 
-    pair_iter++;
-  }
+        ++pair_iter;
+    }
 
-  return option_pair;
+    return option_pair;
 }
 
 gchar **
-lsq_command_option_pair_get_args(LSQCommandOptionPair **pair)
+lsq_command_option_pair_get_args ( LSQCommandOptionPair **pair )
 {
-  int length = 0;
-  LSQCommandOptionPair **option_iter;
-  gchar **argv, **argi;
+    int length = 0;
+    LSQCommandOptionPair **option_iter;
+    gchar **argv, **argi;
 
-  for ( option_iter = pair; NULL != *option_iter; option_iter++ )
-  {
-    length += lsq_command_option_get_args((*option_iter)->option, &(*option_iter)->value, NULL);
-  }
+    g_return_val_if_fail( NULL != pair, NULL);
 
-  argv = g_new0(gchar*, length+1);
-  argi = argv;
+    for ( option_iter = pair; NULL != *option_iter; ++option_iter )
+    {
+        length += lsq_command_option_get_args( (*option_iter)->option, &(*option_iter)->value, NULL );
+    }
 
-  for ( option_iter = pair; NULL != *option_iter; option_iter++ )
-  {
-    argi += lsq_command_option_get_args((*option_iter)->option, &(*option_iter)->value, argi);
-  }
+    argv = g_new0( gchar *, length + 1 );
+    argi = argv;
 
-  return argv;
+    for ( option_iter = pair; NULL != *option_iter; ++option_iter )
+    {
+        argi += lsq_command_option_get_args( (*option_iter)->option, &(*option_iter)->value, argi );
+    }
+
+    return argv;
 }
 
 gint
-lsq_command_option_get_args(const LSQCommandOption *option, GValue *value, gchar **argv)
+lsq_command_option_get_args ( const LSQCommandOption *option, GValue *value, gchar **argv )
 {
-  //TODO
-  return 0;
+    //TODO
+    return 0;
 }
 
 void
-lsq_command_option_get_default(const LSQCommandOption *option, GValue *value)
+lsq_command_option_get_default ( const LSQCommandOption *option, GValue *value )
 {
-  g_return_if_fail ( NULL != LSQ_COMMAND_OPTION_GET_CLASS(option)->get_default );
-  LSQ_COMMAND_OPTION_GET_CLASS(option)->get_default(option, value);
+    g_return_if_fail( LSQ_IS_COMMAND_OPTION( option ) );
+    g_return_if_fail( G_IS_VALUE( value ) );
+    g_return_if_fail( NULL != LSQ_COMMAND_OPTION_GET_CLASS( option )->get_default );
+
+    LSQ_COMMAND_OPTION_GET_CLASS( option )->get_default( option, value );
 }
 
-static void lsq_command_option_bool_get_default(const LSQCommandOptionBool *option, GValue *value)
+static void
+lsq_command_option_bool_get_default ( const LSQCommandOptionBool *option, GValue *value )
 {
-  g_value_set_boolean(value, option->default_value);
+    g_return_if_fail( LSQ_IS_COMMAND_OPTION_BOOL( option ) );
+    g_return_if_fail( G_VALUE_HOLDS_BOOLEAN( value ) );
+
+    g_value_set_boolean(value, option->default_value);
 }
 
-static void lsq_command_option_string_get_default(const LSQCommandOptionString *option, GValue *value)
+static void
+lsq_command_option_string_get_default ( const LSQCommandOptionString *option, GValue *value )
 {
-  if ( NULL != option->default_value )
-  {
-    g_value_set_string(value, option->default_value);
-  }
-//  else
-//    g_value_unset(value);
+    g_return_if_fail( LSQ_IS_COMMAND_OPTION_STRING( option ) );
+    g_return_if_fail( G_VALUE_HOLDS_STRING( value ) );
+
+    if ( NULL != option->default_value )
+    {
+        g_value_set_string( value, option->default_value );
+    }
+    //  else
+    //    g_value_unset(value);
 }
 
-static void lsq_command_option_int_get_default(const LSQCommandOptionInt *option, GValue *value)
+static void
+lsq_command_option_int_get_default ( const LSQCommandOptionInt *option, GValue *value )
 {
-  g_value_set_int(value, option->default_value);
+    g_return_if_fail( LSQ_IS_COMMAND_OPTION_INT( option ) );
+    g_return_if_fail( G_VALUE_HOLDS_INT( value ) );
+
+    g_value_set_int( value, option->default_value );
 }
 
-static void lsq_command_option_uint_get_default(const LSQCommandOptionUint *option, GValue *value)
+static void
+lsq_command_option_uint_get_default ( const LSQCommandOptionUint *option, GValue *value )
 {
-  g_value_set_uint(value, option->default_value);
+    g_return_if_fail( LSQ_IS_COMMAND_OPTION_UINT( option ) );
+    g_return_if_fail( G_VALUE_HOLDS_UINT( value ) );
+
+    g_value_set_uint( value, option->default_value );
 }
 
-static void lsq_command_option_class_init(LSQCommandOptionClass *klass)
+static void
+lsq_command_option_class_init ( LSQCommandOptionClass *klass )
 {
 }
 
-static void lsq_command_option_bool_class_init(LSQCommandOptionClass *klass)
+static void
+lsq_command_option_bool_class_init ( LSQCommandOptionClass *klass )
 {
-  klass->get_default = (LSQCommandOptionGetDefaultFunc)lsq_command_option_bool_get_default;
+    klass->get_default = (LSQCommandOptionGetDefaultFunc)lsq_command_option_bool_get_default;
 }
 
-static void lsq_command_option_string_class_init(LSQCommandOptionClass *klass)
+static void
+lsq_command_option_string_class_init ( LSQCommandOptionClass *klass )
 {
-  klass->get_default = (LSQCommandOptionGetDefaultFunc)lsq_command_option_string_get_default;
+    klass->get_default = (LSQCommandOptionGetDefaultFunc)lsq_command_option_string_get_default;
 }
 
-static void lsq_command_option_int_class_init(LSQCommandOptionClass *klass)
+static void
+lsq_command_option_int_class_init ( LSQCommandOptionClass *klass )
 {
-  klass->get_default = (LSQCommandOptionGetDefaultFunc)lsq_command_option_int_get_default;
+    klass->get_default = (LSQCommandOptionGetDefaultFunc)lsq_command_option_int_get_default;
 }
 
-static void lsq_command_option_uint_class_init(LSQCommandOptionClass *klass)
+static void
+lsq_command_option_uint_class_init ( LSQCommandOptionClass *klass )
 {
-  klass->get_default = (LSQCommandOptionGetDefaultFunc)lsq_command_option_uint_get_default;
+    klass->get_default = (LSQCommandOptionGetDefaultFunc)lsq_command_option_uint_get_default;
 }
 
diff --git a/libsqueeze/command-option.h b/libsqueeze/command-option.h
index 5d24a65..e04389a 100644
--- a/libsqueeze/command-option.h
+++ b/libsqueeze/command-option.h
@@ -46,63 +46,79 @@ typedef struct _LSQCommandOptionInt     LSQCommandOptionInt;
 typedef struct _LSQCommandOptionUint    LSQCommandOptionUint;
 
 GType
-lsq_command_option_get_type(gint);
+lsq_command_option_get_type ( guint ) G_GNUC_CONST;
 
 LSQCommandOptionPair **
-lsq_command_option_create_pair(LSQCommandOption **option_list);
+lsq_command_option_create_pair ( LSQCommandOption **option_list ) G_GNUC_WARN_UNUSED_RESULT;
 
 LSQCommandOption **
-lsq_command_option_create_list(XfceRc *rc, gchar **option_names);
+lsq_command_option_create_list (
+        XfceRc *rc,
+        gchar **option_names
+    ) G_GNUC_WARN_UNUSED_RESULT;
 
 gchar **
-lsq_command_option_pair_get_args(LSQCommandOptionPair **pair);
+lsq_command_option_pair_get_args ( LSQCommandOptionPair **pair ) G_GNUC_WARN_UNUSED_RESULT;
 
 void
-lsq_command_option_get_default(const LSQCommandOption *option, GValue *value);
+lsq_command_option_get_default (
+        const LSQCommandOption *option,
+        GValue *value
+    );
 
 gint
-lsq_command_option_get_args(const LSQCommandOption *option, GValue *value, gchar **argv);
-
-struct _LSQCommandOptionPair {
-  GValue value;
-  const LSQCommandOption *option;
+lsq_command_option_get_args (
+        const LSQCommandOption *option,
+        GValue *value,
+        gchar **argv
+    );
+
+struct _LSQCommandOptionPair
+{
+    GValue value;
+    const LSQCommandOption *option;
 };
 
-struct _LSQCommandOption {
-  GTypeInstance parent;
-  const gchar *name;
-  const gchar *flag;
-  const gchar *blurb;
-  GType value_type;
+struct _LSQCommandOption
+{
+    GTypeInstance parent;
+    const gchar *name;
+    const gchar *flag;
+    const gchar *blurb;
+    GType value_type;
 };
 
-struct _LSQCommandOptionString {
-  LSQCommandOption parent;
+struct _LSQCommandOptionString
+{
+    LSQCommandOption parent;
 
-	const gchar *default_value;
-	const gchar *filter;
+    const gchar *default_value;
+    const gchar *filter;
 };
 
-struct _LSQCommandOptionBool {
-  LSQCommandOption parent;
+struct _LSQCommandOptionBool
+{
+    LSQCommandOption parent;
 
-	gboolean default_value;
+    gboolean default_value;
 };
 
-struct _LSQCommandOptionInt {
-  LSQCommandOption parent;
+struct _LSQCommandOptionInt
+{
+    LSQCommandOption parent;
 
-	gint default_value;
-	gint min_value;
-	gint max_value;
+    gint default_value;
+    gint min_value;
+    gint max_value;
 };
 
-struct _LSQCommandOptionUint {
-  LSQCommandOption parent;
+struct _LSQCommandOptionUint
+{
+    LSQCommandOption parent;
 
-	guint default_value;
-	guint min_value;
-	guint max_value;
+    guint default_value;
+    guint min_value;
+    guint max_value;
 };
 
 #endif /* __LSQ_COMMAND_OPTION_H__ */
diff --git a/libsqueeze/command-queue.c b/libsqueeze/command-queue.c
index 9bb4525..5a4cccc 100644
--- a/libsqueeze/command-queue.c
+++ b/libsqueeze/command-queue.c
@@ -35,647 +35,719 @@ typedef struct _LSQCommandEntry LSQCommandEntry;
 
 struct _LSQCommandEntry
 {
-  LSQCommandEntry *next;
-  gchar *command;
-  GSList *args;
-  gchar *redirect_in;
-  gchar *redirect_out;
+    LSQCommandEntry *next;
+    gchar *command;
+    GSList *args;
+    gchar *redirect_in;
+    gchar *redirect_out;
 };
 
 struct _LSQCommandQueue
 {
-	GObject parent;
+    GObject parent;
 
-  LSQCommandEntry *queue;
+    LSQCommandEntry *queue;
 };
 
 struct _LSQCommandQueueClass
 {
-	GObjectClass parent;
+    GObjectClass parent;
 };
 
 struct _LSQExecuteContext
 {
-  LSQCommandEntry *queue;
-  LSQParser *parser;
-  LSQArchive *archive;
-  gchar **files;
-  gchar *directory;
-  gchar *tempfile;
-  LSQParserContext *ctx;
-  GIOChannel *redir_out;
-  enum {
-    LSQ_EXEC_CTX_STATE_RUNNING = 1<<0,
-    LSQ_EXEC_CTX_STATE_PARSING = 1<<1
-  } state;
+    LSQCommandEntry *queue;
+    LSQParser *parser;
+    LSQArchive *archive;
+    gchar **files;
+    gchar *directory;
+    gchar *tempfile;
+    LSQParserContext *ctx;
+    GIOChannel *redir_out;
+    enum {
+        LSQ_EXEC_CTX_STATE_RUNNING = 1<<0,
+        LSQ_EXEC_CTX_STATE_PARSING = 1<<1
+    } state;
 };
 
-static void lsq_command_entry_start(LSQCommandEntry *entry, LSQExecuteContext *ctx);
+static void
+lsq_command_entry_start ( LSQCommandEntry *entry, LSQExecuteContext *ctx );
+static void
+lsq_command_entry_free ( LSQCommandEntry *entry );
 
-static void build_queue(LSQCommandQueue *queue, const gchar *command_string);
+static gboolean
+build_queue ( LSQCommandQueue *queue, const gchar *command_string );
+
+static void
+lsq_command_queue_finalize ( GObject *object );
+
+G_DEFINE_TYPE( LSQCommandQueue, lsq_command_queue, G_TYPE_OBJECT );
+
+static void
+lsq_command_queue_class_init ( LSQCommandQueueClass *klass )
+{
+    GObjectClass *object_class = G_OBJECT_CLASS( klass );
 
-G_DEFINE_TYPE(LSQCommandQueue, lsq_command_queue, G_TYPE_OBJECT);
+    object_class->finalize = lsq_command_queue_finalize;
+}
 
 static void
-lsq_command_queue_init(LSQCommandQueue *self)
+lsq_command_queue_init ( LSQCommandQueue *self )
 {
 }
 
 static void
-lsq_command_queue_class_init(LSQCommandQueueClass *klass)
+lsq_command_queue_finalize ( GObject *object )
 {
+    LSQCommandEntry *entry, *next;
+
+    LSQCommandQueue *queue = LSQ_COMMAND_QUEUE( object );
+
+    for ( entry = queue->queue; NULL != entry; entry = next )
+    {
+        next = entry->next;
+
+        lsq_command_entry_free( entry );
+    }
 }
 
-LSQCommandQueue *lsq_command_queue_new(const gchar *command_string)
+LSQCommandQueue *
+lsq_command_queue_new ( const gchar *command_string )
 {
-  LSQCommandQueue *queue;
+    LSQCommandQueue *queue;
 
-  g_return_val_if_fail(command_string, NULL);
+    g_return_val_if_fail( command_string, NULL );
 
-  queue = g_object_new(LSQ_TYPE_COMMAND_QUEUE, NULL);
+    queue = g_object_new( LSQ_TYPE_COMMAND_QUEUE, NULL );
 
-  build_queue(queue, command_string);
+    if ( FALSE == build_queue( queue, command_string ) )
+    {
+        g_object_unref( queue );
+        return NULL;
+    }
 
-  return LSQ_COMMAND_QUEUE(queue);
+    return LSQ_COMMAND_QUEUE( queue );
 }
 
-static const gchar *lsq_execute_context_get_temp_file(LSQExecuteContext *ctx)
+static const gchar *
+lsq_execute_context_get_temp_file ( LSQExecuteContext *ctx )
 {
-  if(!ctx->tempfile)
-  {
-    ctx->tempfile = lsq_archive_request_temp_file(ctx->archive, NULL);
-  }
+    g_return_val_if_fail( NULL != ctx, NULL );
 
-  return ctx->tempfile;
+    if ( NULL == ctx->tempfile )
+    {
+        ctx->tempfile = lsq_archive_request_temp_file( ctx->archive, NULL );
+    }
+
+    return ctx->tempfile;
 }
 
-static gchar *format_get_filename(const gchar *format, LSQExecuteContext *ctx)
+static gboolean
+validate_format ( const gchar *format )
 {
-  if((format[0] == '%') && (format[2] == '\0'))
-  {
-    switch(format[1])
+    g_return_val_if_fail( NULL != format, FALSE );
+
+    if ( ( '%' == format[0] ) && ( '\0' == format[2] ) )
     {
-      case 'a':
-        return lsq_archive_get_path (ctx->archive);
-      case 't':
-        return g_strdup(lsq_execute_context_get_temp_file(ctx));
+        switch ( format[1] )
+        {
+            case 'a':
+            case 't':
+                return TRUE;
+        }
     }
-  }
-  return NULL;
+    return FALSE;
 }
 
-static gchar **lsq_command_entry_to_argv(LSQCommandEntry *entry, LSQExecuteContext *ctx)
+static gchar *
+format_get_filename ( const gchar *format, LSQExecuteContext *ctx )
 {
-  gchar **argv, **argi;
-  guint size;
-  GSList *iter;
-  gchar **filei;
-  
-  size = 2;
-
-  for(iter = entry->args; iter; iter = iter->next)
-  {
-    if(0==strcmp((const gchar*)iter->data, "%F"))
+    g_return_val_if_fail( NULL != format, NULL );
+    g_return_val_if_fail( NULL != ctx, NULL );
+
+    if ( ( '%' == format[0] ) && ( '\0' == format[2] ) )
     {
-      if(ctx->files)
-        size += g_strv_length(ctx->files);
+        switch ( format[1] )
+        {
+            case 'a':
+                return lsq_archive_get_path( ctx->archive );
+
+            case 't':
+                return g_strdup( lsq_execute_context_get_temp_file( ctx ) );
+        }
     }
-    else
-      size++;
-  }
+    return NULL;
+}
+
+static gchar **
+lsq_command_entry_to_argv ( LSQCommandEntry *entry, LSQExecuteContext *ctx )
+{
+    gchar **argv, **argi;
+    guint size;
+    GSList *iter;
+    gchar **filei;
+
+    g_return_val_if_fail( NULL != entry, NULL );
+    g_return_val_if_fail( NULL != ctx, NULL );
+
+    size = 2;
 
-  argv = g_new(gchar *, size);
+    for ( iter = entry->args; NULL != iter; iter = iter->next )
+    {
+        if ( 0 == strcmp( (const gchar *)iter->data, "%F" ) )
+        {
+            if ( ctx->files )
+	    {
+                size += g_strv_length( ctx->files );
+	    }
+        }
+        else
+            size++;
+    }
+
+    argv = g_new( gchar *, size );
 
-  argi = argv;
+    argi = argv;
 
-  *argi++ = g_strdup(entry->command);
+    *argi++ = g_strdup( entry->command );
 
-  for(iter = entry->args; iter; iter = iter->next)
-  {
-    const gchar *arg = (const gchar*)iter->data;
-    if((arg[0] == '%') && (arg[2] == '\0'))
+    for ( iter = entry->args; iter; iter = iter->next )
     {
-      switch(arg[1])
-      {
-        case 'F':
-          if(ctx->files)
-          {
-            for(filei = ctx->files; *filei; filei++)
+        const gchar *arg = (const gchar *)iter->data;
+        if ( ( '%' == arg[0] ) && ( '\0' == arg[2] ) )
+        {
+            switch ( arg[1] )
             {
-              *argi++ = g_strdup(*filei);
+                case 'F':
+                    if ( ctx->files )
+                    {
+                        for ( filei = ctx->files; NULL != *filei; filei++ )
+                        {
+                            *argi++ = g_strdup( *filei );
+                        }
+                    }
+                    break;
+
+                case 'a':
+                    *argi++ = lsq_archive_get_path( ctx->archive );
+                    break;
+
+                case 't':
+                    *argi++ = g_strdup( lsq_execute_context_get_temp_file( ctx ) );
+                    break;
+
+                case 'd':
+                    *argi++ = g_strdup( ctx->directory );
+                    break;
+
+                default:
+                    //...
+                    break;
             }
-          }
-          break;
-        case 'a':
-          *argi++ = lsq_archive_get_path(ctx->archive);
-          break;
-        case 't':
-          *argi++ = g_strdup(lsq_execute_context_get_temp_file(ctx));
-          break;
-        case 'd':
-          *argi++ = g_strdup(ctx->directory);
-          break;
-        default:
-          //...
-          break;
-      }
+        }
+        else
+            *argi++ = g_strdup( arg );
     }
-    else
-      *argi++ = g_strdup(arg);
-  }
 
-  *argi = NULL;
+    *argi = NULL;
 
-  return argv;
+    return argv;
 }
 
-static void child_exit(GPid pid, gint status, LSQExecuteContext *ctx)
+static void
+child_exit ( GPid pid, gint status, LSQExecuteContext *ctx )
 {
-  g_spawn_close_pid(pid);
-  ctx->state &= ~LSQ_EXEC_CTX_STATE_RUNNING;
-  if(!ctx->state)
-  {
-    if((ctx->queue = ctx->queue->next))
-      lsq_command_entry_start(ctx->queue, ctx);
+    g_spawn_close_pid( pid );
+    ctx->state &= ~LSQ_EXEC_CTX_STATE_RUNNING;
+    if ( 0 == ctx->state )
+    {
+        ctx->queue = ctx->queue->next;
+        if ( NULL != ctx->queue )
+        {
+            lsq_command_entry_start( ctx->queue, ctx );
+        }
+        else
+        {
+            //...ERROR | DONE//
+        }
+    }
     else
     {
         //...ERROR | DONE//
     }
-  }
-  else
-  {
-        //...ERROR | DONE//
-  }
 }
 
-static void in_channel(GIOChannel *source, GIOCondition condition, GIOChannel *dest)
+static void
+in_channel ( GIOChannel *source, GIOCondition condition, GIOChannel *dest )
 {
-	GIOStatus stat = G_IO_STATUS_NORMAL;
-  static gchar buffer[1024];
-
-  if(condition & G_IO_IN)
-  {
-    gsize n;
-    stat = g_io_channel_read_chars(source, buffer, 1024, &n, NULL);
-    if(stat == G_IO_STATUS_NORMAL)
-      g_io_channel_write_chars(dest, buffer, n, NULL, NULL);
-  }
-
-  if(condition & G_IO_HUP || (stat != G_IO_STATUS_NORMAL && stat != G_IO_STATUS_AGAIN))
-  {
-    g_io_channel_unref(source);
-    g_io_channel_flush(dest, NULL);
-    g_io_channel_unref(dest);
-  }
+    GIOStatus stat = G_IO_STATUS_NORMAL;
+    static gchar buffer[1024];
+
+    if ( G_IO_IN & condition )
+    {
+        gsize n;
+        stat = g_io_channel_read_chars( source, buffer, 1024, &n, NULL );
+        if ( G_IO_STATUS_NORMAL == stat )
+        {
+            g_io_channel_write_chars( dest, buffer, n, NULL, NULL );
+        }
+    }
+
+    if ( G_IO_HUP & condition || ( G_IO_STATUS_NORMAL != stat && G_IO_STATUS_AGAIN != stat ) )
+    {
+        g_io_channel_unref( source );
+        g_io_channel_flush( dest, NULL );
+        g_io_channel_unref( dest );
+    }
 }
 
-static void out_channel(GIOChannel *source, GIOCondition condition, LSQExecuteContext *ctx)
+static void
+out_channel ( GIOChannel *source, GIOCondition condition, LSQExecuteContext *ctx )
 {
-	GIOStatus stat = G_IO_STATUS_NORMAL;
-  GIOChannel *dest = ctx->redir_out;
-  static gchar buffer[1024];
-
-  if(condition & G_IO_IN)
-  {
-    gsize n;
-    stat = g_io_channel_read_chars(source, buffer, 1024, &n, NULL);
-    if(stat == G_IO_STATUS_NORMAL)
-      g_io_channel_write_chars(dest, buffer, n, NULL, NULL);
-  }
-
-  if(condition & G_IO_HUP || (stat != G_IO_STATUS_NORMAL && stat != G_IO_STATUS_AGAIN))
-  {
-    g_io_channel_unref(source);
-    g_io_channel_flush(dest, NULL);
-    g_io_channel_unref(dest);
-    ctx->redir_out = NULL;
-    ctx->state &= ~LSQ_EXEC_CTX_STATE_PARSING;
-    if(!ctx->state)
+    GIOStatus stat = G_IO_STATUS_NORMAL;
+    GIOChannel *dest = ctx->redir_out;
+    static gchar buffer[1024];
+
+    if ( G_IO_IN & condition )
     {
-      if((ctx->queue = ctx->queue->next))
-        lsq_command_entry_start(ctx->queue, ctx);
-      //else
-        //...//done
+        gsize n;
+        stat = g_io_channel_read_chars( source, buffer, 1024, &n, NULL );
+        if ( G_IO_STATUS_NORMAL == stat )
+        {
+            g_io_channel_write_chars( dest, buffer, n, NULL, NULL );
+        }
+    }
+
+    if ( G_IO_HUP & condition || ( G_IO_STATUS_NORMAL != stat && G_IO_STATUS_AGAIN != stat ) )
+    {
+        g_io_channel_unref( source );
+        g_io_channel_flush( dest, NULL );
+        g_io_channel_unref( dest );
+        ctx->redir_out = NULL;
+        ctx->state &= ~LSQ_EXEC_CTX_STATE_PARSING;
+        if ( 0 == ctx->state )
+        {
+            ctx->queue = ctx->queue->next;
+            if ( NULL != ctx->queue )
+            {
+                lsq_command_entry_start( ctx->queue, ctx );
+            }
+            //else
+            //...//done
+        }
     }
-  }
 }
 
 static gboolean
-parse_channel(GIOChannel *source, GIOCondition condition, LSQExecuteContext *ctx)
+parse_channel ( GIOChannel *source, GIOCondition condition, LSQExecuteContext *ctx )
 {
-  if(condition & G_IO_IN)
-  {
-    do {
-      lsq_parser_parse(ctx->parser, ctx->ctx);
-    } while(lsq_parser_context_read_again(ctx->ctx));
-  }
-
-  if(condition & G_IO_HUP || !lsq_parser_context_is_good(ctx->ctx))
-  {
-    lsq_parser_context_set_channel(ctx->ctx, NULL);
-    g_io_channel_unref(source);
-    ctx->state &= ~LSQ_EXEC_CTX_STATE_PARSING;
-    if(!ctx->state)
+    if ( G_IO_IN & condition )
     {
-      if((ctx->queue = ctx->queue->next))
-        lsq_command_entry_start(ctx->queue, ctx);
-      //else
-        //...//done
+        do
+        {
+            lsq_parser_parse( ctx->parser, ctx->ctx );
+        }
+        while ( TRUE == lsq_parser_context_read_again( ctx->ctx ) );
     }
-    //FIXME: this is not entirely the correct place, or is it?
-    lsq_archive_refreshed(ctx->archive);
-    return FALSE;
-  }
-  return TRUE;
+
+    if ( G_IO_HUP & condition || FALSE == lsq_parser_context_is_good( ctx->ctx ) )
+    {
+        lsq_parser_context_set_channel( ctx->ctx, NULL );
+        g_io_channel_unref( source );
+        ctx->state &= ~LSQ_EXEC_CTX_STATE_PARSING;
+        if ( 0 == ctx->state )
+        {
+            ctx->queue = ctx->queue->next;
+            if ( NULL != ctx->queue )
+            {
+                lsq_command_entry_start( ctx->queue, ctx );
+            }
+            //else
+            //...//done
+        }
+        //FIXME: this is not entirely the correct place, or is it?
+        lsq_archive_refreshed( ctx->archive );
+        return FALSE;
+    }
+    return TRUE;
 }
 
-static void lsq_command_entry_start(LSQCommandEntry *entry, LSQExecuteContext *ctx)
+static void
+lsq_command_entry_start ( LSQCommandEntry *entry, LSQExecuteContext *ctx )
 {
-  GError *error = NULL;
-  gint fd_in = FALSE;
-  gint fd_out = TRUE;
-  GIOChannel *redir_in = NULL;
-  GIOChannel *chan_in;
-  GIOChannel *chan_out;
-  gchar **argv;
-  GPid pid;
-  GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL;
-  gchar **argvi;
-  if(entry->redirect_out)
-  {
-    gchar *file = format_get_filename(entry->redirect_out, ctx);
-    ctx->redir_out = g_io_channel_new_file(file, "w", NULL);
-    g_free(file);
-  }
-  else if(!ctx->ctx)
-  {
-    flags |= G_SPAWN_STDOUT_TO_DEV_NULL;
-    fd_out = FALSE;
-  }
-  if(entry->redirect_in)
-  {
-    gchar *file = format_get_filename(entry->redirect_in, ctx);
-    redir_in = g_io_channel_new_file(file, "r", NULL);
-    g_free(file);
-    fd_in = TRUE;
-  }
-
-  argv = lsq_command_entry_to_argv(entry, ctx);
-
-  g_debug("command: %s", argv[0]);
-
-  argvi = argv;
-  while (argvi[1])
-  {
-    g_debug("arg: '%s'", argvi[1]);
-    argvi++;
-  }
-
-  if(!g_spawn_async_with_pipes(NULL, argv, NULL, flags, NULL, NULL, &pid, fd_in?&fd_in:NULL, fd_out?&fd_out:NULL, NULL, &error))
-  {
-    g_debug("spawn failed: %s", error->message);
-    g_error_free(error);
-    return;
-  }
-
-  g_strfreev(argv);
-
-  g_child_watch_add(pid, (GChildWatchFunc)child_exit, ctx);
-  ctx->state |= LSQ_EXEC_CTX_STATE_RUNNING;
-
-  if(entry->redirect_in)
-  {
-    chan_in = g_io_channel_unix_new(fd_in);
-    g_io_add_watch(redir_in, G_IO_IN|G_IO_HUP, (GIOFunc)in_channel, chan_in);
-  }
-  if(entry->redirect_out)
-  {
-    chan_out = g_io_channel_unix_new(fd_out);
-    g_io_add_watch(chan_out, G_IO_IN|G_IO_HUP, (GIOFunc)out_channel, ctx);
-    ctx->state |= LSQ_EXEC_CTX_STATE_PARSING;
-  }
-  else if(ctx->ctx)
-  {
-    chan_out = g_io_channel_unix_new(fd_out);
-    lsq_parser_context_set_channel(ctx->ctx, chan_out);
-    g_io_add_watch(chan_out, G_IO_IN|G_IO_HUP, (GIOFunc)parse_channel, ctx);
-    ctx->state |= LSQ_EXEC_CTX_STATE_PARSING;
-  }
+    GError *error = NULL;
+    gint fd_in = FALSE;
+    gint fd_out = TRUE;
+    GIOChannel *redir_in = NULL;
+    GIOChannel *chan_in;
+    GIOChannel *chan_out;
+    gchar **argv;
+    GPid pid;
+    GSpawnFlags flags = G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL;
+    gchar **argvi;
+
+    g_return_if_fail( NULL != entry );
+    g_return_if_fail( NULL != ctx );
+
+    if ( NULL != entry->redirect_out )
+    {
+        gchar *file = format_get_filename( entry->redirect_out, ctx );
+        ctx->redir_out = g_io_channel_new_file( file, "w", NULL );
+        g_free( file );
+        g_return_if_fail( NULL != ctx->redir_out );
+    }
+    else if ( NULL == ctx->ctx )
+    {
+        flags |= G_SPAWN_STDOUT_TO_DEV_NULL;
+        fd_out = FALSE;
+    }
+    if ( NULL != entry->redirect_in )
+    {
+        gchar *file = format_get_filename( entry->redirect_in, ctx );
+        redir_in = g_io_channel_new_file( file, "r", NULL );
+        g_free( file );
+        g_return_if_fail( NULL != redir_in );
+        fd_in = TRUE;
+    }
+
+    argv = lsq_command_entry_to_argv( entry, ctx );
+
+    g_debug( "command: %s", argv[0] );
+
+#ifdef DEBUG
+    argvi = argv;
+    while ( NULL != argvi[1] )
+    {
+        g_debug( "arg: '%s'", argvi[1] );
+        argvi++;
+    }
+#endif
+
+    if ( FALSE == g_spawn_async_with_pipes( NULL, argv, NULL, flags, NULL, NULL, &pid, ( TRUE == fd_in ) ? &fd_in : NULL, ( TRUE == fd_out ) ? &fd_out : NULL , NULL, &error ) )
+    {
+        g_debug( "spawn failed: %s", error->message );
+        g_error_free( error );
+        return;
+    }
+
+    g_strfreev( argv );
+
+    g_child_watch_add( pid, (GChildWatchFunc)child_exit, ctx );
+    ctx->state |= LSQ_EXEC_CTX_STATE_RUNNING;
+
+    if ( NULL != entry->redirect_in )
+    {
+        chan_in = g_io_channel_unix_new( fd_in );
+        g_return_if_fail( NULL != chan_in );
+        g_io_add_watch( redir_in, G_IO_IN|G_IO_HUP, (GIOFunc)in_channel, chan_in );
+    }
+    if ( NULL != entry->redirect_out )
+    {
+        chan_out = g_io_channel_unix_new( fd_out );
+        g_return_if_fail( NULL != chan_out );
+        g_io_add_watch( chan_out, G_IO_IN|G_IO_HUP, (GIOFunc)out_channel, ctx );
+        ctx->state |= LSQ_EXEC_CTX_STATE_PARSING;
+    }
+    else if ( NULL != ctx->ctx )
+    {
+        chan_out = g_io_channel_unix_new( fd_out );
+        g_return_if_fail( NULL != chan_out );
+        lsq_parser_context_set_channel( ctx->ctx, chan_out );
+        g_io_add_watch( chan_out, G_IO_IN|G_IO_HUP, (GIOFunc)parse_channel, ctx );
+        ctx->state |= LSQ_EXEC_CTX_STATE_PARSING;
+    }
 }
 
-LSQExecuteContext *lsq_command_queue_execute(LSQCommandQueue *queue, LSQArchive *archive, const gchar **files, const gchar *directory, LSQParser *parser)
+LSQExecuteContext *
+lsq_command_queue_execute ( LSQCommandQueue *queue, LSQArchive *archive, gchar **files, const gchar *directory, LSQParser *parser )
 {
-  LSQExecuteContext *ctx;
+    LSQExecuteContext *ctx;
 
-  ctx = g_new0(LSQExecuteContext, 1);
+    g_return_val_if_fail( LSQ_IS_COMMAND_QUEUE( queue ), NULL );
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
 
-  ctx->queue = queue->queue;
-  ctx->archive = archive;
-  ctx->files = g_strdupv((gchar**)files);
-  ctx->directory = g_strdup(directory);
-  ctx->parser = parser;
-  ctx->ctx = parser?lsq_parser_get_context(parser, archive):NULL;
+    ctx = g_new0( LSQExecuteContext, 1 );
 
-  lsq_command_entry_start(ctx->queue, ctx);
+    ctx->queue = queue->queue;
+    ctx->archive = archive;
+    ctx->files = g_strdupv( files );
+    ctx->directory = g_strdup( directory );
+    ctx->parser = parser;
+    ctx->ctx = ( NULL != parser ) ? lsq_parser_get_context( parser, archive ) : NULL;
 
-  return ctx;
+    lsq_command_entry_start( ctx->queue, ctx );
+
+    return ctx;
 }
 
-static gchar* strdup_escaped(const gchar *str, guint lng)/*{{{*/
+static gchar *
+strdup_escaped ( const gchar *str, guint lng )/*{{{*/
 {
-  guint i;
-  gchar *new_str;
-  gchar ch;
-  guint size = 0;
-
-  for(i = 0; i < lng; i++)
-  {
-    switch(str[i])
+    guint i;
+    gchar *new_str;
+    gchar ch;
+    guint size = 0;
+
+    g_return_val_if_fail( NULL != str, NULL );
+
+    for ( i = 0; i < lng; ++i )
     {
-      case '\\':
-        i++;
-        switch(str[i])
+        switch ( str[i] )
         {
-          case 'x':
-            if(g_ascii_isxdigit(str[i+1]))
-            {
-              i++;
-              if(g_ascii_isxdigit(str[i+1]))
-              {
-                i++;
-              }
-            }
-          break;
-          default:
-            ch = str[i+1];
-            if(ch>='0' && ch < '8')
-            {
-              i++;
-              ch = str[i+1];
-              if(ch>='0' && ch < '8')
-              {
-                ch = str[i];
-                i++;
-                if(ch < '4')
+            case '\\':
+                ++i;
+                switch ( str[i] )
                 {
-                  ch = str[i+1];
-                  if(str[i+1]>='0' && str[i+1] < '8')
-                  {
-                    i++;
-                  }
+                    case 'x':
+                        if ( g_ascii_isxdigit( str[i+1] ) )
+                        {
+                            ++i;
+                            if ( g_ascii_isxdigit( str[i+1] ) )
+                            {
+                                ++i;
+                            }
+                        }
+                        break;
+
+                    default:
+                        ch = str[i+1];
+                        if ( '0' <= ch && '8' > ch )
+                        {
+                            ++i;
+                            ch = str[i+1];
+                            if ( '0' <= ch && '8' > ch )
+                            {
+                                ch = str[i];
+                                ++i;
+                                if ( '4' > ch )
+                                {
+                                    ch = str[i+1];
+                                    if ( '0' <= str[i+1] && '8' > str[i+1] )
+                                    {
+                                        ++i;
+                                    }
+                                }
+                            }
+                        }
+                        break;
                 }
-              }
-            }
-          break;
+                break;
         }
-      break;
+        ++size;
     }
-    size++;
-  }
 
-  new_str = g_new(gchar, size+1);
-  new_str[size] = '\0';
+    new_str = g_new( gchar, size + 1 );
+    new_str[size] = '\0';
 
-  size = 0;
-  for(i = 0; i < lng; i++)
-  {
-    switch(ch = str[i])
+    size = 0;
+    for ( i = 0; i < lng; ++i )
     {
-      case '\\':
-        i++;
-        switch(ch = str[i])
+        ch = str[i];
+        switch ( ch )
         {
-          case 'a':
-            ch = '\a';
-          break;
-          case 'b':
-            ch = '\b';
-          break;
-          case 'f':
-            ch = '\f';
-          break;
-          case 'n':
-            ch = '\n';
-          break;
-          case 'r':
-            ch = '\r';
-          break;
-          case 't':
-            ch = '\t';
-          break;
-          case 'v':
-            ch = '\v';
-          break;
-          case 'x':
-            if(g_ascii_isxdigit(str[i+1]))
-            {
-              i++;
-              ch = g_ascii_xdigit_value(str[i]);
-              if(g_ascii_isxdigit(str[i+1]))
-              {
-                i++;
-                ch = (ch*0x10) + g_ascii_xdigit_value(str[i]);
-              }
-            }
-          break;
-          default:
-            if(str[i+1]>='0' && str[i+1] < '8')
-            {
-              i++;
-              ch = str[i]-'0';
-              if(str[i+1]>='0' && str[i+1] < '8')
-              {
-                i++;
-                if((ch = (ch*010) + (str[i]-'0')) < 040)
+            case '\\':
+                ++i;
+                ch = str[i];
+                switch ( ch )
                 {
-                  if(str[i+1]>='0' && str[i+1] < '8')
-                  {
-                    i++;
-                    ch = (ch*010) + (str[i]-'0');
-                  }
+                    case 'a':
+                        ch = '\a';
+                        break;
+
+                    case 'b':
+                        ch = '\b';
+                        break;
+
+                    case 'f':
+                        ch = '\f';
+                        break;
+
+                    case 'n':
+                        ch = '\n';
+                        break;
+
+                    case 'r':
+                        ch = '\r';
+                        break;
+
+                    case 't':
+                        ch = '\t';
+                        break;
+
+                    case 'v':
+                        ch = '\v';
+                        break;
+
+                    case 'x':
+                        if ( TRUE == g_ascii_isxdigit( str[i+1] ) )
+                        {
+                            ++i;
+                            ch = g_ascii_xdigit_value( str[i] );
+                            if ( TRUE == g_ascii_isxdigit( str[i+1] ) )
+                            {
+                                ++i;
+                                ch = ( ch * 0x10 ) + g_ascii_xdigit_value( str[i] );
+                            }
+                        }
+                        break;
+
+                    default:
+                        if ( '0' <= str[i+1] && '8' > str[i+1] )
+                        {
+                            ++i;
+                            ch = str[i] - '0';
+                            if ( '0' <= str[i+1] && '8' > str[i+1] )
+                            {
+                                ++i;
+                                ch = ( ch * 010 ) + ( str[i] - '0' );
+                                if ( 040 > ch )
+                                {
+                                    if ( '0' <= str[i+1] && '8' > str[i+1] )
+                                    {
+                                        ++i;
+                                        ch = ( ch * 010 ) + ( str[i] - '0' );
+                                    }
+                                }
+                            }
+                        }
+                        break;
                 }
-              }
-            }
-          break;
+                break;
         }
-      break;
+        new_str[size++] = ch;
     }
-    new_str[size++] = ch;
-  }
 
-  return new_str;
+    return new_str;
 }/*}}}*/
 
-static void build_queue(LSQCommandQueue *queue, const gchar *command_string)
+static gboolean
+build_queue ( LSQCommandQueue *queue, const gchar *command_string )
 {
-  const gchar *ptr;
-  const gchar *cur;
-  gchar ch;
-  enum {
-    STATE_COMMAND,
-    STATE_ARGS,
-    STATE_REDIRECT,
-    STATE_FINISH
-  } state = STATE_COMMAND;
-
-  LSQCommandEntry *command = g_new0(LSQCommandEntry, 1);
-  LSQCommandEntry *commands = command;
-  LSQCommandEntry *prev_cmd = NULL;
-
-  gchar **direct_to = NULL;
-
-  cur = ptr = command_string;
-
-  while((ch = *ptr++))
-  {
-    switch(ch)
+    const gchar *ptr;
+    const gchar *cur;
+    gchar ch;
+    enum {
+        STATE_COMMAND,
+        STATE_ARGS,
+        STATE_REDIRECT,
+        STATE_FINISH
+    } state = STATE_COMMAND;
+
+    LSQCommandEntry *command;
+    LSQCommandEntry *prev_cmd = NULL;
+
+    gchar **direct_to = NULL;
+
+    g_return_val_if_fail( LSQ_IS_COMMAND_QUEUE( queue ), FALSE );
+    g_return_val_if_fail( NULL != command_string, FALSE );
+
+    queue->queue = command = g_new0( LSQCommandEntry, 1 );
+
+    cur = ptr = command_string;
+
+    do
     {
-      case '\\':
-        if(*ptr)
-          ptr++;
-      break;
-      case ';':
-        if(cur+1 != ptr)
-        {
-          switch(state)
-          {
-            case STATE_COMMAND:
-              command->command = strdup_escaped(cur, (ptr-cur)-1);
-              state = STATE_ARGS;
-            break;
-            case STATE_ARGS:
-              command->args = g_slist_append(command->args, strdup_escaped(cur, (ptr-cur)-1));
-            break;
-            case STATE_REDIRECT:
-              g_return_if_fail(cur[0] == '%');
-              *direct_to = strdup_escaped(cur, (ptr-cur)-1);
-              state = STATE_FINISH;
-            break;
-            case STATE_FINISH:
-              g_return_if_reached();
-            break;
-          }
-        }
-        cur = ptr;
-        g_return_if_fail(state == STATE_ARGS || state == STATE_FINISH);
-        prev_cmd = command;
-        prev_cmd->next = command = g_new0(LSQCommandEntry, 1);
-        direct_to = NULL;
-        state = STATE_COMMAND;
-      break;
-      case '>':
-        if(cur+1 != ptr)
+        ch = *ptr++;
+        /* Split the code into multiple pieces, so multiple switch statements on ch */
+        /* Check for data separators and finish previous state */
+        switch ( ch )
         {
-          switch(state)
-          {
-            case STATE_COMMAND:
-              command->command = strdup_escaped(cur, (ptr-cur)-1);
-              state = STATE_ARGS;
-            break;
-            case STATE_ARGS:
-              command->args = g_slist_append(command->args, strdup_escaped(cur, (ptr-cur)-1));
-            break;
-            case STATE_REDIRECT:
-              g_return_if_fail(cur[0] == '%');
-              *direct_to = strdup_escaped(cur, (ptr-cur)-1);
-              state = STATE_FINISH;
-            break;
-            case STATE_FINISH:
-              g_return_if_reached();
-            break;
-          }
+            case '\0':
+            case ';':
+            case '>':
+            case '<':
+            case ' ':
+            case '\t':
+                if ( cur + 1 != ptr )
+                {
+                    switch ( state )
+                    {
+                        case STATE_COMMAND:
+                            command->command = strdup_escaped( cur, ( ptr - cur ) - 1 );
+                            state = STATE_ARGS;
+                            break;
+
+                        case STATE_ARGS:
+                            command->args = g_slist_append( command->args, strdup_escaped( cur, ( ptr - cur ) - 1 ) );
+                            break;
+
+                        case STATE_REDIRECT:
+                            /* We only support redirecting to %a or %t */
+                            *direct_to = strdup_escaped( cur, ( ptr - cur ) - 1 );
+                            if ( FALSE == validate_format( *direct_to ) )
+                            {
+                                g_warning( "Invalid redirect near character %"G_GSIZE_FORMAT" in \'%s\'", (gsize)(cur - command_string), command_string );
+                                return FALSE;
+                            }
+                            state = STATE_FINISH;
+                            break;
+
+                        case STATE_FINISH:
+                            g_warning( "Trailing data near character %"G_GSIZE_FORMAT" in \'%s\'", (gsize)(cur - command_string), command_string );
+                            return FALSE;
+                    }
+                }
+                cur = ptr;
+                break;
         }
-        cur = ptr;
-        g_return_if_fail(state == STATE_ARGS || state == STATE_FINISH);
-        direct_to = &command->redirect_out;
-        state = STATE_REDIRECT;
-      break;
-      break;
-      case '<':
-        if(cur+1 != ptr)
+        /* Check for invalid stats on command part separators */
+        switch ( ch )
         {
-          switch(state)
-          {
-            case STATE_COMMAND:
-              command->command = strdup_escaped(cur, (ptr-cur)-1);
-              state = STATE_ARGS;
-            break;
-            case STATE_ARGS:
-              command->args = g_slist_append(command->args, strdup_escaped(cur, (ptr-cur)-1));
-            break;
-            case STATE_REDIRECT:
-              g_return_if_fail(cur[0] == '%');
-              *direct_to = strdup_escaped(cur, (ptr-cur)-1);
-              state = STATE_FINISH;
-            break;
-            case STATE_FINISH:
-              g_return_if_reached();
-            break;
-          }
+            case '\0':
+            case ';':
+            case '>':
+            case '<':
+                if ( STATE_ARGS != state && STATE_FINISH != state )
+                {
+                    g_warning( "Incomplete %s near character %"G_GSIZE_FORMAT" in \'%s\'", ( STATE_REDIRECT == state ) ? "redirect" : "command", (gsize)(cur - command_string), command_string );
+                    return FALSE;
+                }
+                break;
         }
-        cur = ptr;
-        g_return_if_fail(state == STATE_ARGS || state == STATE_FINISH);
-        direct_to = &command->redirect_in;
-        state = STATE_REDIRECT;
-      break;
-      case ' ':
-      case '\t':
-        if(cur+1 != ptr)
+        /* Setup the next state */
+        switch ( ch )
         {
-          switch(state)
-          {
-            case STATE_COMMAND:
-              command->command = strdup_escaped(cur, (ptr-cur)-1);
-              state = STATE_ARGS;
-            break;
-            case STATE_ARGS:
-              command->args = g_slist_append(command->args, strdup_escaped(cur, (ptr-cur)-1));
-            break;
-            case STATE_REDIRECT:
-              g_return_if_fail(cur[0] == '%');
-              *direct_to = strdup_escaped(cur, (ptr-cur)-1);
-              state = STATE_FINISH;
-            break;
-            case STATE_FINISH:
-              g_return_if_reached();
-            break;
-          }
+            case '\\':
+                if ( '\0' != *ptr )
+                {
+                    ptr++;
+                }
+                break;
+
+            case ';':
+                prev_cmd = command;
+                prev_cmd->next = command = g_new0( LSQCommandEntry, 1 );
+                direct_to = NULL;
+                state = STATE_COMMAND;
+                break;
+
+            case '>':
+                direct_to = &command->redirect_out;
+                state = STATE_REDIRECT;
+                break;
+
+            case '<':
+                direct_to = &command->redirect_in;
+                state = STATE_REDIRECT;
+                break;
         }
-        cur = ptr;
-      break;
     }
-  }
+    while ( '\0' !=  ch );
 
-  if(cur+1 != ptr)
-  {
-    switch(state)
-    {
-      case STATE_COMMAND:
-        command->command = strdup_escaped(cur, (ptr-cur)-1);
-        state = STATE_ARGS;
-      break;
-      case STATE_ARGS:
-        command->args = g_slist_append(command->args, strdup_escaped(cur, (ptr-cur)-1));
-      break;
-      case STATE_REDIRECT:
-        g_return_if_fail(cur[0] == '%');
-        *direct_to = strdup_escaped(cur, (ptr-cur)-1);
-        state = STATE_FINISH;
-      break;
-      case STATE_FINISH:
-        g_return_if_reached();
-      break;
-    }
-  }
-  g_return_if_fail(state == STATE_ARGS || state == STATE_FINISH);
+    return TRUE;
+}
+
+static void
+lsq_command_entry_free ( LSQCommandEntry *entry )
+{
+    g_return_if_fail( NULL != entry );
 
-  if(!command->command)
-  {
-    g_return_if_fail(prev_cmd);
-    prev_cmd->next = NULL;
-    g_free(command);
-  }
+    g_free( entry->command );
+    g_slist_foreach( entry->args, (GFunc)g_free, NULL );
+    g_slist_free( entry->args );
+    g_free( entry->redirect_in );
+    g_free( entry->redirect_out );
 
-  queue->queue = commands;
+    g_free( entry );
 }
 
diff --git a/libsqueeze/command-queue.h b/libsqueeze/command-queue.h
index fa28b17..03f8e1c 100644
--- a/libsqueeze/command-queue.h
+++ b/libsqueeze/command-queue.h
@@ -20,28 +20,28 @@ G_BEGIN_DECLS
 
 #define LSQ_TYPE_COMMAND_QUEUE lsq_command_queue_get_type()
 
-#define LSQ_COMMAND_QUEUE(obj) (			   \
-		G_TYPE_CHECK_INSTANCE_CAST ((obj),  \
-			LSQ_TYPE_COMMAND_QUEUE,				  \
-			LSQCommandQueue))
+#define LSQ_COMMAND_QUEUE(obj) ( \
+        G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+            LSQ_TYPE_COMMAND_QUEUE, \
+            LSQCommandQueue))
 
-#define LSQ_IS_COMMAND_QUEUE(obj) (			\
-		G_TYPE_CHECK_INSTANCE_TYPE ((obj),  \
-			LSQ_TYPE_COMMAND_QUEUE))
+#define LSQ_IS_COMMAND_QUEUE(obj) ( \
+        G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+            LSQ_TYPE_COMMAND_QUEUE))
 
-#define LSQ_COMMAND_QUEUE_CLASS(class) (	  \
-		G_TYPE_CHECK_CLASS_CAST ((class),  \
-			LSQ_TYPE_COMMAND_QUEUE,				 \
-			LSQCommandQueueClass))
+#define LSQ_COMMAND_QUEUE_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_CAST ((klass), \
+            LSQ_TYPE_COMMAND_QUEUE, \
+            LSQCommandQueueClass))
 
-#define LSQ_IS_COMMAND_QUEUE_CLASS(class) (   \
-		G_TYPE_CHECK_CLASS_TYPE ((class),  \
-			LSQ_TYPE_COMMAND_QUEUE))
+#define LSQ_IS_COMMAND_QUEUE_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_TYPE ((klass), \
+            LSQ_TYPE_COMMAND_QUEUE))
 
-#define LSQ_COMMAND_QUEUE_GET_CLASS(obj) (	\
-		G_TYPE_INSTANCE_GET_CLASS ((obj),  \
-			LSQ_TYPE_COMMAND_QUEUE,				 \
-	  LSQCommandQueueClass))
+#define LSQ_COMMAND_QUEUE_GET_CLASS(obj) ( \
+        G_TYPE_INSTANCE_GET_CLASS ((obj), \
+            LSQ_TYPE_COMMAND_QUEUE, \
+            LSQCommandQueueClass))
 
 #if 0
 typedef struct _LSQCommandQueue LSQCommandQueue;
@@ -52,11 +52,20 @@ typedef struct _LSQCommandQueueClass LSQCommandQueueClass;
 typedef struct _LSQExecuteContext LSQExecuteContext;
 
 
-GType		   lsq_command_queue_get_type(void);
+GType
+lsq_command_queue_get_type ( void ) G_GNUC_CONST;
 
-LSQCommandQueue *lsq_command_queue_new(const gchar *command_string);
+LSQCommandQueue *
+lsq_command_queue_new ( const gchar *command_string ) G_GNUC_WARN_UNUSED_RESULT;
 
-LSQExecuteContext *lsq_command_queue_execute(LSQCommandQueue *queue, LSQArchive *archive, const gchar **files, const gchar *direcotry, LSQParser *parser);
+LSQExecuteContext *
+lsq_command_queue_execute (
+        LSQCommandQueue *queue,
+        LSQArchive *archive,
+        gchar **files,
+        const gchar *direcotry,
+        LSQParser *parser
+    ) G_GNUC_WARN_UNUSED_RESULT;
 
 
 G_END_DECLS
diff --git a/libsqueeze/datetime.c b/libsqueeze/datetime.c
index 9e3ad78..1402034 100644
--- a/libsqueeze/datetime.c
+++ b/libsqueeze/datetime.c
@@ -66,7 +66,8 @@ value_init_datetime ( GValue *value )
 static void
 value_copy_datetime (
         const GValue *src_value,
-        GValue *dest_value )
+        GValue *dest_value
+    )
 {
     dest_value->data[0].v_int64 = src_value->data[0].v_int64;
 }
@@ -76,7 +77,8 @@ value_collect_datetime (
         GValue *value,
         guint n_collect_values,
         GTypeCValue *collect_values,
-        guint collect_flags )
+        guint collect_flags
+    )
 {
     value->data[0].v_int64 = collect_values[0].v_int64;
 
@@ -88,7 +90,8 @@ value_lcopy_datetime (
         const GValue *value,
         guint n_collect_values,
         GTypeCValue *collect_values,
-        guint collect_flags )
+        guint collect_flags
+    )
 {
     gint64 *int64_p = collect_values[0].v_pointer;
 
@@ -103,7 +106,8 @@ value_lcopy_datetime (
 static void
 value_datetime_to_string (
         const GValue *src_value,
-        GValue *dest_value )
+        GValue *dest_value
+    )
 {
     gchar buffer[80]; /* An abitrary size to fit the time string in */
     struct tm timeval;
@@ -122,7 +126,7 @@ lsq_datetime_get_type ( void )
 {
     static GType type = G_TYPE_INVALID;
 
-    if ( G_UNLIKELY( G_TYPE_INVALID == type ) )
+    if ( G_UNLIKELY ( G_TYPE_INVALID == type ) )
     {
         GTypeValueTable value_table = {
             value_init_datetime,
@@ -171,14 +175,16 @@ lsq_datetime_register_type ( void )
 {
     /* Force lsq_datetime_get_type to get called, and not optimized by G_GNUC_CONST */
     volatile GType type;
-    type  = lsq_datetime_get_type();
+    type = lsq_datetime_get_type();
     type;
 }
 
 LSQDateTime
 lsq_datetime_from_tm ( const struct tm *timeval )
 {
+#ifdef DEBUG
     g_return_val_if_fail( NULL != timeval, LSQ_DATETIME_NULL );
+#endif
 
     return (
             TM_X_MAKE( SEC, timeval->tm_sec ) |
@@ -189,20 +195,24 @@ lsq_datetime_from_tm ( const struct tm *timeval )
             TM_X_MAKE( YEAR, timeval->tm_year ) |
             TM_X_MAKE( WDAY, timeval->tm_wday ) |
             TM_X_MAKE( YDAY, timeval->tm_yday ) |
-            TM_X_MAKE( ISDST, timeval->tm_isdst ));
+            TM_X_MAKE( ISDST, timeval->tm_isdst )
+        );
 }
 
 LSQDateTime
 lsq_datetime_from_string (
         const gchar *str,
         const gchar *format,
-        gchar **endp )
+        gchar **endp
+    )
 {
     struct tm timeval;
     LSQDateTime dt = LSQ_DATETIME_NULL;
 
+#ifdef DEBUG
     g_return_val_if_fail( NULL != str, LSQ_DATETIME_NULL );
     g_return_val_if_fail( NULL != format, LSQ_DATETIME_NULL );
+#endif
 
     str = strptime( str, format, &timeval );
 
@@ -210,7 +220,7 @@ lsq_datetime_from_string (
     {
         if ( NULL != endp )
         {
-            *endp = (gchar*)str;
+            *endp = (gchar *)str;
         }
 
         dt = lsq_datetime_from_tm( &timeval );
@@ -222,8 +232,10 @@ lsq_datetime_from_string (
 void
 lsq_datetime_to_tm ( LSQDateTime dt, struct tm *timeval )
 {
+#ifdef DEBUG
     g_return_if_fail( LSQ_DATETIME_NULL!= dt );
     g_return_if_fail( NULL != timeval );
+#endif
 
     memset( timeval, 0, sizeof(struct tm) );
 
@@ -258,13 +270,15 @@ lsq_datetime_cmp (
     if ( 0 != cmp )
         return cmp;
 
-    return difftime( mktime( (struct tm*)a ), mktime( (struct tm*)b ) );
+    return difftime( mktime( (struct tm *)a ), mktime( (struct tm *)b ) );
 }
 
 LSQDateTime
 g_value_get_datetime ( const GValue *value )
 {
+#ifdef DEBUG
     g_return_val_if_fail( G_VALUE_HOLDS_DATETIME( value ), LSQ_DATETIME_NULL );
+#endif
 
     return value->data[0].v_int64;
 }
@@ -274,7 +288,9 @@ g_value_set_datetime (
         GValue *value,
         LSQDateTime v_dt )
 {
+#ifdef DEBUG
     g_return_if_fail( G_VALUE_HOLDS_DATETIME( value ) );
+#endif
 
     value->data[0].v_int64 = v_dt;
 }
diff --git a/libsqueeze/datetime.h b/libsqueeze/datetime.h
index fbc534c..4d42c86 100644
--- a/libsqueeze/datetime.h
+++ b/libsqueeze/datetime.h
@@ -35,29 +35,35 @@ void
 lsq_datetime_register_type ( void );
 
 LSQDateTime
-lsq_datetime_from_tm ( const struct tm * );
+lsq_datetime_from_tm ( const struct tm * ) G_GNUC_PURE;
 
 LSQDateTime
 lsq_datetime_from_string (
         const gchar *,
         const gchar *,
-        gchar ** );
+        gchar **
+    ) G_GNUC_PURE;
 
 void
-lsq_datetime_to_tm ( LSQDateTime, struct tm * );
+lsq_datetime_to_tm (
+        LSQDateTime,
+        struct tm *
+    );
 
 gint
 lsq_datetime_cmp (
         LSQDateTime,
-        LSQDateTime );
+        LSQDateTime
+    ) G_GNUC_CONST;
 
 LSQDateTime
-g_value_get_datetime ( const GValue * );
+g_value_get_datetime ( const GValue * ) G_GNUC_PURE;
 
 void
 g_value_set_datetime (
         GValue *,
-        LSQDateTime );
+        LSQDateTime
+    );
 
 
 G_END_DECLS
diff --git a/libsqueeze/internals.c b/libsqueeze/internals.c
index b51202c..e3cb072 100644
--- a/libsqueeze/internals.c
+++ b/libsqueeze/internals.c
@@ -41,26 +41,28 @@
 static gint
 lsq_opened_archives_lookup_archive (
         gconstpointer open_archive,
-        gconstpointer path);
+        gconstpointer path
+    );
 
 gchar *
 lsq_concat_filenames ( GSList *filenames )
 {
     GSList *_filenames = filenames;
-    gchar *concat_str = g_strdup(" "), *_concat_str;
+    gchar *concat_str = g_strdup( " " ), *_concat_str;
 
     while ( NULL != _filenames )
     {
         _concat_str = concat_str;
-        concat_str = g_strconcat (
+        concat_str = g_strconcat(
                 concat_str,
                 " ",
-                g_shell_quote ( _filenames->data ),
-                NULL );
+                g_shell_quote( _filenames->data ),
+                NULL
+            );
 
         _filenames = _filenames->next;
 
-        g_free ( _concat_str );
+        g_free( _concat_str );
     }
     return concat_str;
 }
@@ -68,15 +70,19 @@ lsq_concat_filenames ( GSList *filenames )
 LSQArchive *
 lsq_opened_archive_get_archive ( gchar *path )
 {
-    GSList *result = g_slist_find_custom (
+    GSList *result;
+
+    g_return_val_if_fail( NULL != path, NULL );
+
+    result = g_slist_find_custom(
             lsq_opened_archive_list,
             path,
-            lsq_opened_archives_lookup_archive );
+            lsq_opened_archives_lookup_archive
+        );
 
     if ( NULL != result )
     {
-        g_object_ref ( result->data );
-        return result->data;
+        return g_object_ref( result->data );
     }
     return NULL;
 }
@@ -85,24 +91,26 @@ lsq_opened_archive_get_archive ( gchar *path )
 static gint
 lsq_opened_archives_lookup_archive (
         gconstpointer open_archive,
-        gconstpointer uri )
+        gconstpointer uri
+    )
 {
     GFile *file;
     GFile *archive_file;
-#ifdef DEBUG
-    g_return_val_if_fail ( NULL != open_archive, 1 );
-#endif
-    file = g_file_new_for_path ( uri );
-    archive_file = lsq_archive_get_file ( LSQ_ARCHIVE ( open_archive ) );
+
+    g_return_val_if_fail( NULL != open_archive, 1 );
+    g_return_val_if_fail( NULL != uri, 1 );
+
+    file = g_file_new_for_path( uri );
+    archive_file = lsq_archive_get_file( LSQ_ARCHIVE( open_archive ) );
     
-    if ( TRUE == g_file_equal (archive_file , file) )
+    if ( TRUE == g_file_equal( archive_file , file ) )
     {
-        g_object_unref ( file );
+        g_object_unref( file );
 
         return 0;
     }
 
-    g_object_unref ( file );
+    g_object_unref( file );
 
     return 1;
 }
diff --git a/libsqueeze/internals.h b/libsqueeze/internals.h
index c76afe2..25cfa2a 100644
--- a/libsqueeze/internals.h
+++ b/libsqueeze/internals.h
@@ -14,18 +14,19 @@
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-GSList  *support_factory_list;
-GSList  *lsq_mime_support_list;
-GSList  *lsq_opened_archive_list;
-gchar   *lsq_relative_base_uri;
+GSList *support_factory_list;
+GSList *lsq_mime_support_list;
+GSList *lsq_opened_archive_list;
+gchar  *lsq_relative_base_uri;
 
 gchar *
-lsq_concat_filenames ( GSList *filenames );
+lsq_concat_filenames ( GSList *filenames ) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
 gchar *
 lsq_concat_iter_filenames (
         GSList *file_iters,
-        gboolean );
+        gboolean
+    ) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
 LSQArchive *
-lsq_opened_archive_get_archive ( gchar *path );
+lsq_opened_archive_get_archive ( gchar *path ) G_GNUC_WARN_UNUSED_RESULT;
diff --git a/libsqueeze/libsqueeze-view.h b/libsqueeze/libsqueeze-view.h
index e940a53..fe41776 100644
--- a/libsqueeze/libsqueeze-view.h
+++ b/libsqueeze/libsqueeze-view.h
@@ -18,74 +18,81 @@
 G_BEGIN_DECLS
 
 gboolean
-lsq_archive_iter_is_real ( const LSQArchiveIter * );
+lsq_archive_iter_is_real ( const LSQArchiveIter * ) G_GNUC_PURE;
 
 LSQArchiveIter *
-lsq_archive_iter_get_real_parent ( LSQArchiveIter * );
+lsq_archive_iter_get_real_parent ( LSQArchiveIter * ) G_GNUC_WARN_UNUSED_RESULT;
 
 gboolean
-lsq_archive_iter_is_directory ( const LSQArchiveIter * );
+lsq_archive_iter_is_directory ( const LSQArchiveIter * ) G_GNUC_PURE;
 
 guint
-lsq_archive_iter_n_children ( const LSQArchiveIter * );
+lsq_archive_iter_n_children ( const LSQArchiveIter * ) G_GNUC_PURE;
 
 LSQArchiveIter *
 lsq_archive_iter_nth_child (
         LSQArchiveIter *,
-        guint);
+        guint
+    ) G_GNUC_WARN_UNUSED_RESULT;
 
 LSQArchiveIter *
 lsq_archive_iter_get_child (
         LSQArchiveIter *,
-        const gchar *);
+        const gchar *
+    ) G_GNUC_WARN_UNUSED_RESULT;
 guint
-lsq_archive_iter_get_depth ( const LSQArchiveIter * );
+lsq_archive_iter_get_depth ( const LSQArchiveIter * ) G_GNUC_PURE;
 
 gboolean
-lsq_archive_iter_has_parent ( const LSQArchiveIter * );
+lsq_archive_iter_has_parent ( const LSQArchiveIter * ) G_GNUC_PURE;
 
 LSQArchiveIter *
-lsq_archive_iter_get_parent ( LSQArchiveIter * );
+lsq_archive_iter_get_parent ( LSQArchiveIter * ) G_GNUC_WARN_UNUSED_RESULT;
 
 gboolean
 lsq_archive_iter_get_prop_value (
         const LSQArchiveIter *iter,
         guint n,
-        GValue *value );
+        GValue *value
+    );
 
 const gchar *
-lsq_archive_iter_get_filename ( const LSQArchiveIter * );
+lsq_archive_iter_get_filename ( const LSQArchiveIter * ) G_GNUC_PURE;
 
 const gchar *
-lsq_archive_iter_get_contenttype ( const LSQArchiveIter * );
+lsq_archive_iter_get_contenttype ( const LSQArchiveIter * ) G_GNUC_PURE;
 
 gchar *
-lsq_archive_iter_get_path ( const LSQArchiveIter *archive );
+lsq_archive_iter_get_path ( const LSQArchiveIter *archive ) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
 LSQArchiveIter *
 lsq_archive_get_iter (
         LSQArchive *archive,
-        const gchar *path );
+        const gchar *path
+    ) G_GNUC_WARN_UNUSED_RESULT;
 
 GType
 lsq_archive_get_entry_property_type (
         const LSQArchive *archive,
-        guint n );
+        guint n
+    ) G_GNUC_PURE;
 guint
 lsq_archive_get_entry_property_offset (
         const LSQArchive *archive,
-        guint n );
+        guint n
+    ) G_GNUC_PURE;
 
 const gchar *
 lsq_archive_get_entry_property_name (
         const LSQArchive *archive,
-        guint n );
+        guint n
+    ) G_GNUC_PURE;
 
 guint
-lsq_archive_n_entry_properties ( const LSQArchive *archive );
+lsq_archive_n_entry_properties ( const LSQArchive *archive ) G_GNUC_PURE;
 
 guint
-lsq_archive_entry_properties_size ( const LSQArchive *archive );
+lsq_archive_entry_properties_size ( const LSQArchive *archive ) G_GNUC_PURE;
 
 gboolean
 lsq_archive_can_stop ( const LSQArchive *archive );
@@ -97,7 +104,7 @@ const gchar *
 lsq_archive_get_status ( const LSQArchive *archive );
 
 GSList *
-lsq_iter_slist_copy ( GSList * );
+lsq_iter_slist_copy ( GSList * ) G_GNUC_WARN_UNUSED_RESULT;
 
 void
 lsq_iter_slist_free ( GSList * );
diff --git a/libsqueeze/libsqueeze.c b/libsqueeze/libsqueeze.c
index a62aef0..063f8b9 100644
--- a/libsqueeze/libsqueeze.c
+++ b/libsqueeze/libsqueeze.c
@@ -33,73 +33,80 @@
 #include "internals.h"
 
 static void
-lsq_read_squeeze_dir(const gchar *dir)
+lsq_read_squeeze_dir ( const gchar *dir )
 {
-  const gchar *filename;
-  GDir *data_dir = g_dir_open(dir, 0, NULL);
+    const gchar *filename;
+    GDir *data_dir;
 
-  if (data_dir)
-  {
-    while((filename = g_dir_read_name(data_dir)) != NULL)
+    g_return_if_fail( NULL != dir );
+
+    data_dir = g_dir_open( dir, 0, NULL );
+
+    if ( NULL != data_dir)
     {
-      if(g_str_has_suffix(filename, ".squeeze"))
-      {
-	/* see if a file with this name was already loaded.
-	 * skip this file. configuration was overruled
-	 */
-	if ( NULL == g_slist_find_custom(support_factory_list, filename, (GCompareFunc)lsq_suport_factory_compare_filename) )
-	{
-	  /**
-	   * FIXME: factories should be per-mime-type, not per-template
-	   */
-	  gchar *path = g_strconcat(dir, "/", filename, NULL);
-	  LSQSupportFactory *factory = lsq_support_reader_parse_file(path);
-	  if(factory)
-	  {
-	    support_factory_list = g_slist_append(support_factory_list, factory);
-	  }
-	  g_free(path);
-	}
-      }
+        filename = g_dir_read_name( data_dir );
+        while ( NULL != filename )
+        {
+            if ( g_str_has_suffix( filename, ".squeeze" ) )
+            {
+                /* see if a file with this name was already loaded.
+                 * skip this file. configuration was overruled
+                 */
+                if ( NULL == g_slist_find_custom( support_factory_list, filename, (GCompareFunc)lsq_suport_factory_compare_filename ) )
+                {
+                    /**
+                     * FIXME: factories should be per-mime-type, not per-template
+                     */
+                    gchar *path = g_build_filename( dir, filename, NULL );
+                    LSQSupportFactory *factory = lsq_support_reader_parse_file( path );
+                    if ( NULL != factory )
+                    {
+                        support_factory_list = g_slist_append( support_factory_list, factory );
+                    }
+                    g_free( path );
+                }
+            }
+        }
+
+        g_dir_close( data_dir );
     }
-
-    g_dir_close(data_dir);
-  }
 }
 
 void
-lsq_init(void)
+lsq_init ( void )
 {
-  gchar *data_squeeze;
-  const gchar* const* system_dirs = g_get_system_data_dirs ();
-  const gchar* user_dir = g_get_user_data_dir ();
+    gchar *data_squeeze;
+    const gchar * const *system_dirs = g_get_system_data_dirs();
+    const gchar *user_dir = g_get_user_data_dir();
 
-  lsq_datetime_register_type();
+    lsq_datetime_register_type();
 
-  support_factory_list = NULL;
+    support_factory_list = NULL;
 
-  lsq_opened_archive_list = NULL;
+    lsq_opened_archive_list = NULL;
 
-  data_squeeze = g_build_path("/", user_dir, "squeeze", NULL);
-  lsq_read_squeeze_dir(data_squeeze);
-  g_free(data_squeeze);
+    data_squeeze = g_build_filename( user_dir, "squeeze", NULL );
+    lsq_read_squeeze_dir( data_squeeze );
+    g_free( data_squeeze );
 
-  data_squeeze = g_build_path("/", DATADIR, "squeeze", NULL);
-  lsq_read_squeeze_dir(data_squeeze);
-  g_free(data_squeeze);
+    data_squeeze = g_build_filename( DATADIR, "squeeze", NULL );
+    lsq_read_squeeze_dir( data_squeeze );
+    g_free( data_squeeze );
 
-  for (; NULL != *system_dirs; ++system_dirs)
-  {
-    data_squeeze = g_build_path("/", *system_dirs, "squeeze", NULL);
-    lsq_read_squeeze_dir(data_squeeze);
-    g_free(data_squeeze);
-  }
+    for ( ; NULL != *system_dirs; ++system_dirs )
+    {
+        data_squeeze = g_build_filename( *system_dirs, "squeeze", NULL );
+        lsq_read_squeeze_dir( data_squeeze );
+        g_free( data_squeeze );
+    }
 }
 
 void
-lsq_shutdown(void)
+lsq_shutdown ( void )
 {
-	g_slist_foreach(lsq_opened_archive_list, (GFunc)lsq_close_archive, NULL);
+    g_slist_foreach( lsq_opened_archive_list, (GFunc)lsq_close_archive, NULL );
+    g_slist_foreach( support_factory_list, (GFunc)g_object_unref, NULL );
+    g_slist_free( support_factory_list );
 }
 
 /*
@@ -107,26 +114,31 @@ lsq_shutdown(void)
  *
  */
 gint
-lsq_new_archive(GFile *file, gboolean overwrite, LSQArchive **lp_archive)
+lsq_new_archive ( GFile *file, gboolean overwrite, LSQArchive **lp_archive )
 {
-	LSQArchive *archive;
+    LSQArchive *archive;
+
+    g_return_val_if_fail( G_IS_FILE( file ), 1 );
+    g_return_val_if_fail( NULL != lp_archive, 1 );
 
-	if(overwrite)
+    if ( TRUE == overwrite )
     {
-        g_file_trash (file, NULL, NULL);
+        g_file_trash( file, NULL, NULL );
     }
 
-	if(g_file_query_exists(file, NULL))
-	{
-		(*lp_archive) = NULL;
-		return 1;
-	}
-
-	archive = lsq_archive_new(file);
-	(*lp_archive) = archive;
-	if(!archive)
-		return 1;
-	return 0;
+    if ( TRUE == g_file_query_exists( file, NULL ) )
+    {
+        (*lp_archive) = NULL;
+        return 1;
+    }
+
+    archive = lsq_archive_new( file );
+    (*lp_archive) = archive;
+    if( NULL == archive )
+    {
+        return 1;
+    }
+    return 0;
 }
 
 /*
@@ -135,62 +147,70 @@ lsq_new_archive(GFile *file, gboolean overwrite, LSQArchive **lp_archive)
  *
  */
 gint
-lsq_open_archive(GFile *file, LSQArchive **lp_archive)
+lsq_open_archive ( GFile *file, LSQArchive **lp_archive )
 {
-	LSQArchive *archive = NULL; /*lsq_opened_archive_get_archive(path); */
-
-	if(!g_file_query_exists (file, NULL))
-	{
-		(*lp_archive) = NULL;
-		return 1;
-	}
-
-	if(!archive)
-	{
-		archive = lsq_archive_new(file);
-		if(archive)
-			lsq_opened_archive_list = g_slist_prepend(lsq_opened_archive_list, archive);
-	}
-	(*lp_archive) = archive;
-	if(!archive)
-		return 1;
-	return 0;
+    LSQArchive *archive = NULL; /*lsq_opened_archive_get_archive(path); */
+
+    g_return_val_if_fail( G_IS_FILE( file ), 1 );
+    g_return_val_if_fail( NULL != lp_archive, 1 );
+
+    if ( FALSE == g_file_query_exists( file, NULL ) )
+    {
+        (*lp_archive) = NULL;
+        return 1;
+    }
+
+    if ( NULL == archive )
+    {
+        archive = lsq_archive_new( file );
+        if ( NULL != archive )
+        {
+            /* FIXME: Shouldn't this be part of lsq_archive_new? */
+            lsq_opened_archive_list = g_slist_prepend( lsq_opened_archive_list, archive );
+        }
+    }
+    (*lp_archive) = archive;
+    if( NULL == archive )
+    {
+        return 1;
+    }
+    return 0;
 }
 
 gboolean
-lsq_is_supported(const gchar *filename)
+lsq_is_supported ( const gchar *filename )
 {
-	return FALSE;
+    return FALSE;
 }
 
 GSList *
-lsq_get_supported_mime_types(LSQCommandType type)
+lsq_get_supported_mime_types ( LSQCommandType type )
 {
-	return NULL;
+    return NULL;
 }
 
-const gchar **
-lsq_iter_list_to_strv(GSList *list)
+gchar **
+lsq_iter_list_to_strv ( GSList *list )
 {
-  guint i;
+    GSList *iter;
+    guint i;
 
-  const gchar **strv;
+    gchar **strv;
 
-  if(!list)
-    return NULL;
+    if(!list)
+        return NULL;
 
-  strv = g_new(const gchar *, g_slist_length(list)+1);
+    strv = g_new( gchar *, g_slist_length( list ) + 1 );
 
-  i = 0;
+    i = 0;
 
-  while(list)
-  {
-    strv[i++] = lsq_archive_iter_get_filename(list->data);
-    list = g_slist_next(list);
-  }
+    for ( iter = list; NULL != iter; iter = g_slist_next( iter ) )
+    {
+        strv[i++] = lsq_archive_iter_get_path( iter->data );
+    }
 
-  strv[i] = NULL;
+    strv[i] = NULL;
 
-  return strv;
+    return strv;
 }
 
diff --git a/libsqueeze/libsqueeze.h b/libsqueeze/libsqueeze.h
index 965e054..287c729 100644
--- a/libsqueeze/libsqueeze.h
+++ b/libsqueeze/libsqueeze.h
@@ -34,13 +34,13 @@ G_BEGIN_DECLS
  * void
  * lsq_init()
  */
-void lsq_init(void);
+void lsq_init ( void );
 
 /*
  * void
  * lsq_shutdown()
  */
-void lsq_shutdown(void);
+void lsq_shutdown ( void );
 
 /*
  * gint
@@ -53,9 +53,11 @@ void lsq_shutdown(void);
  * 0 -- success
  */
 gint
-lsq_new_archive( GFile *,
-				 gboolean overwrite,
-				 LSQArchive **lp_archive);
+lsq_new_archive (
+        GFile *,
+        gboolean overwrite,
+        LSQArchive **lp_archive
+    );
 
 /*
  * gint 
@@ -66,8 +68,10 @@ lsq_new_archive( GFile *,
  * 0 -- success
  */
 gint
-lsq_open_archive( GFile *, 
-				  LSQArchive **lp_archive);
+lsq_open_archive (
+        GFile *, 
+        LSQArchive **lp_archive
+    );
 
 /*
  * void 
@@ -75,16 +79,16 @@ lsq_open_archive( GFile *,
  *
  */
 void 
-lsq_close_archive( LSQArchive *archive );
+lsq_close_archive ( LSQArchive *archive );
 
 GSList *
-lsq_get_supported_mime_types(LSQCommandType type);
+lsq_get_supported_mime_types ( LSQCommandType type );
 
 gboolean
-lsq_is_supported(const gchar *filename);
+lsq_is_supported ( const gchar *filename );
 
-const gchar **
-lsq_iter_list_to_strv(GSList *list);
+gchar **
+lsq_iter_list_to_strv ( GSList *list ) G_GNUC_WARN_UNUSED_RESULT;
 
 G_END_DECLS
 
diff --git a/libsqueeze/parser-context.c b/libsqueeze/parser-context.c
index 56e6e14..9e38b44 100644
--- a/libsqueeze/parser-context.c
+++ b/libsqueeze/parser-context.c
@@ -37,14 +37,16 @@ lsq_parser_context_set_property (
         GObject *,
         guint,
         const GValue *,
-        GParamSpec * );
+        GParamSpec *
+    );
 
 static void
 lsq_parser_context_get_property (
         GObject *,
         guint,
         GValue *,
-        GParamSpec * );
+        GParamSpec *
+    );
 
 G_DEFINE_TYPE ( LSQParserContext, lsq_parser_context, G_TYPE_OBJECT );
 
@@ -65,8 +67,8 @@ lsq_parser_context_class_init ( LSQParserContextClass *klass )
     object_class->set_property = lsq_parser_context_set_property;
     object_class->get_property = lsq_parser_context_get_property;
 
-    pspec = g_param_spec_object("archive", NULL, NULL, LSQ_TYPE_ARCHIVE, G_PARAM_READABLE|G_PARAM_WRITABLE|G_PARAM_CONSTRUCT_ONLY);
-    g_object_class_install_property(object_class, LSQ_PARSER_CONTEXT_PROPERTY_ARCHIVE, pspec);
+    pspec = g_param_spec_object( "archive", NULL, NULL, LSQ_TYPE_ARCHIVE, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY );
+    g_object_class_install_property( object_class, LSQ_PARSER_CONTEXT_PROPERTY_ARCHIVE, pspec );
 }
 
 static void
@@ -74,12 +76,13 @@ lsq_parser_context_set_property (
         GObject *object,
         guint property_id,  
         const GValue *value,
-        GParamSpec *pspec )
+        GParamSpec *pspec
+    )
 {
     switch ( property_id )
     {
         case LSQ_PARSER_CONTEXT_PROPERTY_ARCHIVE:
-            LSQ_PARSER_CONTEXT ( object )->archive = g_value_get_object ( value );
+            LSQ_PARSER_CONTEXT ( object )->archive = g_value_get_object( value );
             break;
     }
 }
@@ -89,28 +92,30 @@ lsq_parser_context_get_property (
         GObject *object,
         guint property_id,
         GValue *value,
-        GParamSpec *pspec )
+        GParamSpec *pspec
+    )
 {
     switch ( property_id )
     {
         case LSQ_PARSER_CONTEXT_PROPERTY_ARCHIVE:
-            g_value_set_object ( value, LSQ_PARSER_CONTEXT ( object )->archive );
+            g_value_set_object( value, LSQ_PARSER_CONTEXT ( object )->archive );
             break;
     }
 }
 
-LSQParserContext*
+LSQParserContext *
 lsq_parser_context_new ( LSQArchive *archive )
 {
     LSQParserContext *ctx;
 
-    g_return_val_if_fail ( LSQ_IS_ARCHIVE ( archive ), NULL );
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
 
-    ctx = g_object_new (
+    ctx = g_object_new(
             LSQ_TYPE_PARSER_CONTEXT,
             "archive",
             archive,
-            NULL);
+            NULL
+        );
        
     return ctx;
 }
@@ -118,8 +123,12 @@ lsq_parser_context_new ( LSQArchive *archive )
 void
 lsq_parser_context_set_channel (
         LSQParserContext *ctx,
-        GIOChannel *channel )
+        GIOChannel *channel
+    )
 {
+    g_return_if_fail( LSQ_IS_PARSER_CONTEXT( ctx ) );
+    g_return_if_fail( NULL != ctx );
+
     ctx->channel = channel;
     ctx->last_stat = G_IO_STATUS_AGAIN;
 }
@@ -128,11 +137,17 @@ gboolean
 lsq_parser_context_get_line (
         LSQParserContext *ctx,
         gchar **line,
-        gsize *length )
+        gsize *length
+    )
 {
     GIOStatus stat;
 
-    g_return_val_if_fail(ctx->channel, FALSE);
+#if DEBUG
+    g_return_val_if_fail( LSQ_IS_PARSER_CONTEXT( ctx ), FALSE);
+    g_return_val_if_fail( NULL != line, FALSE);
+    g_return_val_if_fail( NULL != length, FALSE);
+    g_return_val_if_fail( NULL != ctx->channel, FALSE);
+#endif
 
     stat = g_io_channel_read_line(ctx->channel, line, length, NULL, NULL);
 
@@ -144,11 +159,19 @@ lsq_parser_context_get_line (
 gboolean
 lsq_parser_context_is_good ( LSQParserContext *ctx )
 {
+#if DEBUG
+    g_return_val_if_fail( LSQ_IS_PARSER_CONTEXT( ctx ), FALSE);
+#endif
+
     return ctx->last_stat == G_IO_STATUS_NORMAL || ctx->last_stat == G_IO_STATUS_AGAIN;
 }
 
 gboolean
 lsq_parser_context_read_again ( LSQParserContext *ctx )
 {
+#if DEBUG
+    g_return_val_if_fail( LSQ_IS_PARSER_CONTEXT( ctx ), FALSE);
+#endif
+
     return ctx->last_stat == G_IO_STATUS_NORMAL;
 }
diff --git a/libsqueeze/parser-context.h b/libsqueeze/parser-context.h
index 7cbf32d..96a7e4b 100644
--- a/libsqueeze/parser-context.h
+++ b/libsqueeze/parser-context.h
@@ -21,22 +21,22 @@ G_BEGIN_DECLS
 #define LSQ_TYPE_PARSER_CONTEXT lsq_parser_context_get_type()
 
 #define LSQ_PARSER_CONTEXT(obj) ( \
-		G_TYPE_CHECK_INSTANCE_CAST ((obj), \
-			LSQ_TYPE_PARSER_CONTEXT, \
-			LSQParserContext))
+        G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+            LSQ_TYPE_PARSER_CONTEXT, \
+            LSQParserContext))
 
 #define LSQ_IS_PARSER_CONTEXT(obj) ( \
-		G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
-			LSQ_TYPE_PARSER_CONTEXT))
+        G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+            LSQ_TYPE_PARSER_CONTEXT))
 
-#define LSQ_PARSER_CONTEXT_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class), \
-			LSQ_TYPE_PARSER_CONTEXT, \
-			LSQParserContextClass))
+#define LSQ_PARSER_CONTEXT_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_CAST ((klass), \
+            LSQ_TYPE_PARSER_CONTEXT, \
+            LSQParserContextClass))
 
-#define LSQ_IS_PARSER_CONTEXT_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class), \
-			LSQ_TYPE_PARSER_CONTEXT))
+#define LSQ_IS_PARSER_CONTEXT_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_TYPE ((klass), \
+            LSQ_TYPE_PARSER_CONTEXT))
 
 typedef struct _LSQParserContext LSQParserContext;
 
@@ -58,27 +58,29 @@ struct _LSQParserContextClass
 };
 
 GType
-lsq_parser_context_get_type ( void);
+lsq_parser_context_get_type ( void ) G_GNUC_CONST;
 
 LSQParserContext *
-lsq_parser_context_new ( LSQArchive *archive );
+lsq_parser_context_new ( LSQArchive *archive ) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
 gboolean
 lsq_parser_context_get_line (
         LSQParserContext *,
         gchar **,
-        gsize * );
+        gsize *
+    );
 
 gboolean
-lsq_parser_context_is_good  ( LSQParserContext * );
+lsq_parser_context_is_good ( LSQParserContext * ) G_GNUC_PURE;
 
 gboolean
-lsq_parser_context_read_again ( LSQParserContext *);
+lsq_parser_context_read_again ( LSQParserContext *) G_GNUC_PURE;
 
 void
 lsq_parser_context_set_channel (
         LSQParserContext *,
-        GIOChannel * );
+        GIOChannel *
+    );
 
 G_END_DECLS
 
diff --git a/libsqueeze/parser.c b/libsqueeze/parser.c
index ca2578f..baa96ac 100644
--- a/libsqueeze/parser.c
+++ b/libsqueeze/parser.c
@@ -28,11 +28,11 @@
 #include "parser-context.h"
 #include "parser.h"
 
-G_DEFINE_ABSTRACT_TYPE(LSQParser, lsq_parser, G_TYPE_OBJECT);
+G_DEFINE_ABSTRACT_TYPE ( LSQParser, lsq_parser, G_TYPE_OBJECT );
 
 struct _LSQTypeStorageGroup
 {
-    guint size_of;
+    gsize size_of;
     guint n_types;
     GType *types;
 };
@@ -41,31 +41,32 @@ static LSQTypeStorageGroup *storage_groups = NULL;
 static guint storage_group_count = 0;
 
 static void
-lsq_storage_group_add(GType type, guint size_of)
+lsq_storage_group_add ( GType type, gsize size_of )
 {
     guint i;
     LSQTypeStorageGroup *_storage_groups;
     GType *_types;
 
-    for (i = 0; i < storage_group_count; ++i)
+    for ( i = 0; i < storage_group_count; ++i )
     {
-        if (storage_groups[i].size_of <= size_of)
+        if ( storage_groups[i].size_of <= size_of )
         {
             break;
         }
     }
 
-    g_return_if_fail(i <= storage_group_count);
+    g_return_if_fail( i <= storage_group_count );
 
-    if (i == storage_group_count ||
-            storage_groups[i].size_of < size_of)
+    if ( i == storage_group_count ||
+	    storage_groups[i].size_of < size_of
+	)
     {
-        _storage_groups = g_new0(LSQTypeStorageGroup, storage_group_count+1);
+        _storage_groups = g_new0( LSQTypeStorageGroup, storage_group_count + 1 );
 
-        memcpy(_storage_groups, storage_groups, sizeof(LSQTypeStorageGroup) * i);
-        memcpy(_storage_groups + i + 1, storage_groups + i, sizeof(LSQTypeStorageGroup) * (storage_group_count - i));
+        memcpy( _storage_groups, storage_groups, sizeof(LSQTypeStorageGroup) * i );
+        memcpy( _storage_groups + i + 1, storage_groups + i, sizeof(LSQTypeStorageGroup) * ( storage_group_count - i ) );
 
-        g_free(storage_groups);
+        g_free( storage_groups );
         storage_groups = _storage_groups;
         ++storage_group_count;
 
@@ -74,11 +75,11 @@ lsq_storage_group_add(GType type, guint size_of)
         storage_groups[i].types = NULL;
     }
 
-    _types = g_new(GType, storage_groups[i].n_types+1);
+    _types = g_new( GType, storage_groups[i].n_types + 1 );
 
-    memcpy(_types, storage_groups[i].types, sizeof(GType) * storage_groups[i].n_types);
+    memcpy( _types, storage_groups[i].types, sizeof(GType) * storage_groups[i].n_types );
 
-    g_free(storage_groups[i].types);
+    g_free( storage_groups[i].types );
     storage_groups[i].types = _types;
     _types[storage_groups[i].n_types] = type;
     ++storage_groups[i].n_types;
@@ -87,12 +88,16 @@ lsq_storage_group_add(GType type, guint size_of)
 static gboolean
 lsq_storage_group_has_type (
         LSQTypeStorageGroup *storage_group,
-        GType type )
+        GType type
+    )
 {
     guint i;
-    for (i = 0; i < storage_group->n_types; ++i)
+
+    g_return_val_if_fail( NULL != storage_group, FALSE );
+
+    for ( i = 0; i < storage_group->n_types; ++i )
     {
-        if (storage_group->types[i] == type)
+        if ( storage_group->types[i] == type )
         {
             return TRUE;
         }
@@ -111,64 +116,83 @@ lsq_parser_class_init ( LSQParserClass *klass )
 {
     klass->get_context = NULL;
 
-    lsq_storage_group_add(G_TYPE_CHAR, sizeof(gchar));
-    lsq_storage_group_add(G_TYPE_DOUBLE, sizeof(gdouble));
-    lsq_storage_group_add(G_TYPE_FLOAT, sizeof(gfloat));
-    lsq_storage_group_add(G_TYPE_INT, sizeof(gint));
-    lsq_storage_group_add(G_TYPE_INT64, sizeof(gint64));
-    lsq_storage_group_add(G_TYPE_LONG, sizeof(glong));
-    lsq_storage_group_add(G_TYPE_STRING, sizeof(gchar*));
-    lsq_storage_group_add(G_TYPE_UINT, sizeof(guint));
-    lsq_storage_group_add(G_TYPE_UINT64, sizeof(guint64));
-    lsq_storage_group_add(G_TYPE_ULONG, sizeof(gulong));
-    lsq_storage_group_add(LSQ_TYPE_DATETIME, sizeof(LSQDateTime*));
+    lsq_storage_group_add( G_TYPE_CHAR, sizeof(gchar) );
+    lsq_storage_group_add( G_TYPE_DOUBLE, sizeof(gdouble) );
+    lsq_storage_group_add( G_TYPE_FLOAT, sizeof(gfloat) );
+    lsq_storage_group_add( G_TYPE_INT, sizeof(gint) );
+    lsq_storage_group_add( G_TYPE_INT64, sizeof(gint64) );
+    lsq_storage_group_add( G_TYPE_LONG, sizeof(glong) );
+    lsq_storage_group_add( G_TYPE_STRING, sizeof(gchar *) );
+    lsq_storage_group_add( G_TYPE_UINT, sizeof(guint) );
+    lsq_storage_group_add( G_TYPE_UINT64, sizeof(guint64) );
+    lsq_storage_group_add( G_TYPE_ULONG, sizeof(gulong) );
+    lsq_storage_group_add( LSQ_TYPE_DATETIME, sizeof(LSQDateTime) );
 }
 
-LSQParserContext*
+LSQParserContext *
 lsq_parser_get_context (
         LSQParser *self,
-        LSQArchive *archive )
+        LSQArchive *archive
+    )
 {
     LSQParserClass *klass = LSQ_PARSER_GET_CLASS(self);
 
-    g_return_val_if_fail(klass->get_context, NULL);
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+    g_return_val_if_fail( NULL != klass->get_context, NULL );
 
-    return klass->get_context(self, archive);
+    return klass->get_context( self, archive );
 }
 
 void
 lsq_parser_parse (
         LSQParser *self,
-        LSQParserContext *ctx )
+        LSQParserContext *ctx
+    )
 {
     LSQParserClass *klass = LSQ_PARSER_GET_CLASS(self);
 
-    g_return_if_fail(klass->parse);
+#if DEBUG
+    g_return_if_fail( LSQ_IS_PARSER( self ) );
+    g_return_if_fail( LSQ_IS_PARSER_CONTEXT( ctx ) );
+    g_return_if_fail( NULL != klass->parse );
+#endif
 
-    klass->parse(self, ctx);
+    klass->parse( self, ctx );
 }
 
 guint
 lsq_parser_n_properties ( LSQParser *parser )
 {
+#if DEBUG
+    g_return_val_if_fail( LSQ_IS_PARSER( parser ), 0 );
+#endif
+
     return parser->n_properties;
 }
 
 GType
 lsq_parser_get_property_type (
         LSQParser *parser,
-        guint nr )
+        guint nr
+    )
 {
+#if DEBUG
+    g_return_val_if_fail( LSQ_IS_PARSER( parser ), G_TYPE_NONE );
     g_return_val_if_fail(nr < parser->n_properties, G_TYPE_NONE);
+#endif
     return parser->property_types[nr];
 }
 
-guint
+gsize
 lsq_parser_get_property_offset (
         LSQParser *parser,
-        guint nr )
+        guint nr
+    )
 {
+#if DEBUG
+    g_return_val_if_fail( LSQ_IS_PARSER( parser ), 0 );
     g_return_val_if_fail(nr < parser->n_properties, 0);
+#endif
     return parser->property_offset[nr];
 }
 
@@ -176,38 +200,41 @@ void
 lsq_parser_set_property_type (
         LSQParser *parser,
         guint nr,
-        GType type )
+        GType type
+    )
 {
     guint i, j;
     guint size_of, offset = 0;
 
-    if(nr >= parser->n_properties)
+    g_return_if_fail( LSQ_IS_PARSER( parser ) );
+
+    if ( nr >= parser->n_properties )
     {
-        GType *new_list = g_new(GType, nr+1);
-        for(i=0; i < parser->n_properties; ++i)
+        GType *new_list = g_new( GType, nr + 1 );
+        for( i = 0; i < parser->n_properties; ++i )
         {
             new_list[i] = parser->property_types[i];
         }
-        while(i<nr)
+        while( i < nr )
         {
             new_list[i++] = G_TYPE_NONE;
         }
-        g_free(parser->property_types);
+        g_free( parser->property_types );
         parser->property_types = new_list;
-        parser->n_properties = nr+1;
+        parser->n_properties = nr + 1;
 
-        g_free(parser->property_offset);
-        parser->property_offset = g_new(guint, nr+1);
+        g_free( parser->property_offset );
+        parser->property_offset = g_new( guint, nr + 1 );
     }
 
     parser->property_types[nr] = type;
 
-    for (i = 0; i < storage_group_count; ++i)
+    for ( i = 0; i < storage_group_count; ++i )
     {
         size_of = storage_groups[i].size_of;
-        for (j = 0; j < parser->n_properties; ++j)
+        for ( j = 0; j < parser->n_properties; ++j )
         {
-            if (lsq_storage_group_has_type(&storage_groups[i], parser->property_types[j]))
+            if ( TRUE == lsq_storage_group_has_type(&storage_groups[i], parser->property_types[j] ) )
             {
                 guint align = offset % size_of;
                 if ( 0 != align )
@@ -219,23 +246,34 @@ lsq_parser_set_property_type (
                 parser->property_offset[j] = offset / size_of;
                 offset += size_of;
             }
+            else
+            {
+                g_error( "Unsupported property type" );
+            }
         }
     }
 
     parser->properties_size = offset;
 }
 
-guint
+gsize
 lsq_parser_get_properties_size ( LSQParser *parser )
 {
+#if DEBUG
+    g_return_val_if_fail( LSQ_IS_PARSER( parser ), 0 );
+#endif
     return parser->properties_size;
 }
 
 void
 lsq_parser_set_datetime_format (
         LSQParser *parser,
-        const gchar *format )
+        const gchar *format
+    )
 {
+    g_return_if_fail( LSQ_IS_PARSER( parser ) );
+    g_return_if_fail( NULL != format );
+
     g_free( parser->datetime_format );
     parser->datetime_format = g_strdup( format );
 }
diff --git a/libsqueeze/parser.h b/libsqueeze/parser.h
index 8d8a283..2797a71 100644
--- a/libsqueeze/parser.h
+++ b/libsqueeze/parser.h
@@ -20,27 +20,27 @@ G_BEGIN_DECLS
 
 #define LSQ_TYPE_PARSER lsq_parser_get_type()
 
-#define LSQ_PARSER(obj) (               \
-        G_TYPE_CHECK_INSTANCE_CAST ((obj),  \
-            LSQ_TYPE_PARSER,                  \
+#define LSQ_PARSER(obj) ( \
+        G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+            LSQ_TYPE_PARSER, \
             LSQParser))
 
-#define LSQ_IS_PARSER(obj) (            \
-        G_TYPE_CHECK_INSTANCE_TYPE ((obj),  \
+#define LSQ_IS_PARSER(obj) ( \
+        G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
             LSQ_TYPE_PARSER))
 
-#define LSQ_PARSER_CLASS(class) (      \
-        G_TYPE_CHECK_CLASS_CAST ((class),  \
-            LSQ_TYPE_PARSER,                 \
+#define LSQ_PARSER_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_CAST ((klass), \
+            LSQ_TYPE_PARSER, \
             LSQParserClass))
 
-#define LSQ_IS_PARSER_CLASS(class) (   \
-        G_TYPE_CHECK_CLASS_TYPE ((class),  \
+#define LSQ_IS_PARSER_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_TYPE ((klass), \
             LSQ_TYPE_PARSER))
 
-#define LSQ_PARSER_GET_CLASS(obj) (    \
-        G_TYPE_INSTANCE_GET_CLASS ((obj),  \
-            LSQ_TYPE_PARSER,                 \
+#define LSQ_PARSER_GET_CLASS(obj) ( \
+        G_TYPE_INSTANCE_GET_CLASS ((obj), \
+            LSQ_TYPE_PARSER, \
             LSQParserClass))
 
 
@@ -67,7 +67,7 @@ struct _LSQParserClass
 {
     GObjectClass parent;
 
-    LSQParserContext*
+    LSQParserContext *
     (*get_context)(
             LSQParser *,
             LSQArchive * );
@@ -80,44 +80,50 @@ struct _LSQParserClass
 
 
 GType
-lsq_parser_get_type ( void );
+lsq_parser_get_type ( void ) G_GNUC_CONST;
 
-LSQParserContext*
+LSQParserContext *
 lsq_parser_get_context (
         LSQParser *,
-        LSQArchive * );
+        LSQArchive *
+    ) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
 
 void
 lsq_parser_parse (
         LSQParser *,
-        LSQParserContext * );
+        LSQParserContext *
+    );
 
 guint
-lsq_parser_n_properties ( LSQParser * );
+lsq_parser_n_properties ( LSQParser * ) G_GNUC_PURE;
 
 GType
 lsq_parser_get_property_type (
         LSQParser *,
-        guint );
+        guint
+    ) G_GNUC_PURE;
 
 void
 lsq_parser_set_property_type (
         LSQParser *,
         guint,
-        GType );
+        GType
+    );
 
-guint
+gsize
 lsq_parser_get_property_offset (
         LSQParser *,
-        guint );
+        guint
+    ) G_GNUC_PURE;
 
-guint
-lsq_parser_get_properties_size ( LSQParser * );
+gsize
+lsq_parser_get_properties_size ( LSQParser * ) G_GNUC_PURE;
 
 void
 lsq_parser_set_datetime_format (
         LSQParser *,
-        const gchar * );
+        const gchar *
+    );
 
 G_END_DECLS
 
diff --git a/libsqueeze/pcre-parser.c b/libsqueeze/pcre-parser.c
index c98769f..72151f1 100644
--- a/libsqueeze/pcre-parser.c
+++ b/libsqueeze/pcre-parser.c
@@ -36,7 +36,7 @@ typedef struct _type_parser type_parser;
 typedef struct _LSQPcreParserContext LSQPcreParserContext;
 typedef struct _LSQPcreParserContextClass LSQPcreParserContextClass;
 
-typedef void (*LSQParseFunc)( gchar*, guint, LSQArchiveIter*, guint, LSQPcreParser* );
+typedef void (*LSQParseFunc)( gchar *, guint, LSQArchiveIter *, guint, LSQPcreParser * );
 
 struct _type_parser
 {
@@ -56,7 +56,9 @@ struct _LSQPcreParserContextClass
     LSQParserContextClass parent;
 };
 
-GType lsq_pcre_parser_context_get_type ( void );
+GType
+lsq_pcre_parser_context_get_type ( void );
+#define LSQ_IS_PCRE_PARSER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), lsq_pcre_parser_context_get_type()))
 
 struct _LSQPcreParser
 {
@@ -77,7 +79,10 @@ struct _LSQPcreParserClass
     LSQParserClass parent;
 };
 
-G_DEFINE_TYPE( LSQPcreParserContext, lsq_pcre_parser_context, LSQ_TYPE_PARSER_CONTEXT );
+static void
+lsq_pcre_parser_finalize ( GObject *object );
+
+G_DEFINE_TYPE ( LSQPcreParserContext, lsq_pcre_parser_context, LSQ_TYPE_PARSER_CONTEXT );
 
 static void
 lsq_pcre_parser_context_init ( LSQPcreParserContext *self )
@@ -99,11 +104,13 @@ lsq_pcre_parser_context_new ( LSQPcreParser *parser, LSQArchive *archive )
     return LSQ_PARSER_CONTEXT( ctx );
 }
 
-static void build_parser ( LSQPcreParser *, const gchar *, gchar ** );
+static gboolean
+build_parser ( LSQPcreParser *, const gchar *, gchar ** );
 
-static void lsq_pcre_parser_parse ( LSQPcreParser *, LSQPcreParserContext * );
+static void
+lsq_pcre_parser_parse ( LSQPcreParser *, LSQPcreParserContext * );
 
-G_DEFINE_TYPE( LSQPcreParser, lsq_pcre_parser, LSQ_TYPE_PARSER );
+G_DEFINE_TYPE ( LSQPcreParser, lsq_pcre_parser, LSQ_TYPE_PARSER );
 
 static void
 lsq_pcre_parser_init ( LSQPcreParser *self )
@@ -114,8 +121,23 @@ static void
 lsq_pcre_parser_class_init ( LSQPcreParserClass *klass )
 {
     LSQParserClass *parser_class = LSQ_PARSER_CLASS( klass );
-    parser_class->get_context = (LSQParserContext*(*)(LSQParser*,LSQArchive*))lsq_pcre_parser_context_new;
-    parser_class->parse = (void(*)(LSQParser*,LSQParserContext*))lsq_pcre_parser_parse;
+
+    G_OBJECT_CLASS(klass)->finalize = lsq_pcre_parser_finalize;
+
+    parser_class->get_context = (LSQParserContext *(*)(LSQParser *,LSQArchive *))lsq_pcre_parser_context_new;
+    parser_class->parse = (void(*)(LSQParser *,LSQParserContext *))lsq_pcre_parser_parse;
+}
+
+static void
+lsq_pcre_parser_finalize ( GObject *object )
+{
+    LSQPcreParser *parser = LSQ_PCRE_PARSER(object);
+
+    pcre_free( parser->study );
+    pcre_free( parser->parser );
+    g_free( parser->types_list );
+
+    G_OBJECT_CLASS(lsq_pcre_parser_parent_class)->finalize( object );
 }
 
 LSQParser *
@@ -126,7 +148,11 @@ lsq_pcre_parser_new ( const gchar *parser_string, gchar **parser_types )
     parser = g_object_new( LSQ_TYPE_PCRE_PARSER, NULL );
 
     /* Build the parser base on the provided configuration */
-    build_parser( parser, parser_string, parser_types );
+    if ( FALSE == build_parser( parser, parser_string, parser_types ) )
+    {
+        g_object_unref( parser );
+        return NULL;
+    }
 
     return LSQ_PARSER( parser );
 }
@@ -153,7 +179,7 @@ static void parse_##func(gchar *str, guint lng, LSQArchiveIter *iter, guint n, L
 }
 
 static void
-parse_char( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParser *parser )
+parse_char ( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParser *parser )
 {
     gchar val;
 
@@ -163,21 +189,21 @@ parse_char( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParser
     lsq_archive_iter_set_prop( iter, n, &val );
 }
 
-DEF_PARSE_NUM(decimal, 10, gint)
-DEF_PARSE_NUM(decimal16, 10, gint)
-DEF_PARSE_NUM(decimal32, 10, glong)
-DEF_PARSE_NUM(decimal64, 10, gint64)
+DEF_PARSE_NUM ( decimal, 10, gint )
+DEF_PARSE_NUM ( decimal16, 10, gint )
+DEF_PARSE_NUM ( decimal32, 10, glong )
+DEF_PARSE_NUM ( decimal64, 10, gint64 )
 
-DEF_PARSE_FLOAT(floatingpoint, gfloat)
-DEF_PARSE_FLOAT(double, gdouble)
+DEF_PARSE_FLOAT ( floatingpoint, gfloat )
+DEF_PARSE_FLOAT ( double, gdouble )
 
-DEF_PARSE_UNS(octal, 010, guint)
-DEF_PARSE_UNS(octal16, 010, guint)
-DEF_PARSE_UNS(octal32, 010, gulong)
-DEF_PARSE_UNS(octal64, 010, guint64)
+DEF_PARSE_UNS ( octal, 010, guint )
+DEF_PARSE_UNS ( octal16, 010, guint )
+DEF_PARSE_UNS ( octal32, 010, gulong )
+DEF_PARSE_UNS ( octal64, 010, guint64 )
 
 static void
-parse_string( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParser *parser )
+parse_string ( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParser *parser )
 {
     gchar *val;
 
@@ -188,7 +214,7 @@ parse_string( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParse
 }
 
 static void
-parse_datetime( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParser *parser )
+parse_datetime ( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcreParser *parser )
 {
     LSQDateTime val;
 
@@ -206,17 +232,17 @@ parse_datetime( gchar *str, guint lng, LSQArchiveIter *iter, guint n, LSQPcrePar
     lsq_archive_iter_set_prop( iter, n, &val );
 }
 
-DEF_PARSE_UNS(unsigned, 10, guint)
-DEF_PARSE_UNS(unsigned16, 10, guint)
-DEF_PARSE_UNS(unsigned32, 10, gulong)
-DEF_PARSE_UNS(unsigned64, 10, guint64)
+DEF_PARSE_UNS ( unsigned, 10, guint )
+DEF_PARSE_UNS ( unsigned16, 10, guint )
+DEF_PARSE_UNS ( unsigned32, 10, gulong )
+DEF_PARSE_UNS ( unsigned64, 10, guint64 )
 
-DEF_PARSE_UNS(hexadecimal, 0x10, guint)
-DEF_PARSE_UNS(hexadecimal16, 0x10, guint)
-DEF_PARSE_UNS(hexadecimal32, 0x10, gulong)
-DEF_PARSE_UNS(hexadecimal64, 0x10, guint64)
+DEF_PARSE_UNS ( hexadecimal, 0x10, guint )
+DEF_PARSE_UNS ( hexadecimal16, 0x10, guint )
+DEF_PARSE_UNS ( hexadecimal32, 0x10, gulong )
+DEF_PARSE_UNS ( hexadecimal64, 0x10, guint64 )
 
-static void
+static gboolean
 build_parser ( LSQPcreParser *parser, const gchar *parser_string, gchar **parser_types )
 {
     const char *error;
@@ -224,6 +250,10 @@ build_parser ( LSQPcreParser *parser, const gchar *parser_string, gchar **parser
     gint i = 0;
     gchar **iter;
 
+    g_return_val_if_fail( LSQ_IS_PCRE_PARSER( parser ), FALSE );
+    g_return_val_if_fail( NULL != parser_string, FALSE );
+    g_return_val_if_fail( NULL != parser_types, FALSE );
+
     /* TODO: Should we use g_strstr instead? */
     /* If we want to support multiline matching without the (?m) flag we need to remove the starting lines one by one if no match was found.
      * This is not to difficult, we could just pass the middle of the string to pcre_exec. And this will improve speed. */
@@ -240,8 +270,8 @@ build_parser ( LSQPcreParser *parser, const gchar *parser_string, gchar **parser
 
     if ( NULL == parser->parser )
     {
-        g_error( "%s at %d in '%s'", error, error_pos, parser_string );
-        return;
+        g_warning( "%s at %d in '%s'", error, error_pos, parser_string );
+        return FALSE;
     }
 
     /* Study the regex for optimizations */
@@ -253,15 +283,21 @@ build_parser ( LSQPcreParser *parser, const gchar *parser_string, gchar **parser
 
     if ( NULL != error )
     {
-        g_error( "%s during study of '%s'", error, parser_string );
+        g_warning( "%s during study of '%s'", error, parser_string );
+        return FALSE;
     }
 
     parser->filename_index = pcre_get_stringnumber( parser->parser, "F" );
+    if ( PCRE_ERROR_NOSUBSTRING == parser->filename_index )
+    {
+        g_warning( "Named substring '%s' not found in '%s'", "F", parser_string );
+        return FALSE;
+    }
 
     /* Create a list for type conversion for the found substrings */
     parser->types_list = g_new( type_parser, g_strv_length( parser_types ) );
 
-    for ( iter = parser_types; *iter; ++iter, ++i)
+    for ( iter = parser_types; *iter; ++iter, ++i )
     {
         gchar *name;
         gchar *ptr;
@@ -283,12 +319,19 @@ build_parser ( LSQPcreParser *parser, const gchar *parser_string, gchar **parser
         ptr = strchr( *iter, '=' );
         if ( NULL == ptr )
         {
-            return;
+            g_warning( "No type in '%s'", *iter );
+            return FALSE;
         }
 
         /* Store the index of the <submatch name> to retrieve the value during parsing */
         name = g_strndup( *iter, ptr - *iter );
         type_iter->index = pcre_get_stringnumber( parser->parser, name );
+        if ( PCRE_ERROR_NOSUBSTRING == type_iter->index )
+        {
+            g_warning( "Named substring '%s' not found in '%s'", name, parser_string );
+            g_free( name );
+            return FALSE;
+        }
         g_free( name );
 
         ++ptr;          /* Move past the '=' */
@@ -317,7 +360,11 @@ build_parser ( LSQPcreParser *parser, const gchar *parser_string, gchar **parser
         switch ( ch )
         {
             case 'c':   /* Single character */
-                g_return_if_fail( SIZE_NORMAL == size_flag );
+                if ( SIZE_NORMAL != size_flag )
+                {
+                    g_warning( "Unexpected size flag near character %"G_GSIZE_FORMAT" in '%s'", (gsize)(ptr - *iter - 1), *iter );
+                    return FALSE;
+                }
                 type_iter->function = parse_char;
                 type = G_TYPE_CHAR;
                 break;
@@ -349,7 +396,11 @@ build_parser ( LSQPcreParser *parser, const gchar *parser_string, gchar **parser
                 break;
 
             case 'f':   /* Floating point */
-                g_return_if_fail( SIZE_NORMAL == size_flag || SIZE_LONGLONG == size_flag );
+                if ( SIZE_NORMAL != size_flag && SIZE_LONGLONG != size_flag )
+                {
+                    g_warning( "Unexpected size flag near character %"G_GSIZE_FORMAT" in '%s'", (gsize)(ptr - *iter - 1), *iter );
+                    return FALSE;
+                }
                 switch(size_flag)
                 {
                     case SIZE_NORMAL:
@@ -393,11 +444,21 @@ build_parser ( LSQPcreParser *parser, const gchar *parser_string, gchar **parser
                 break;
 
             case 's':   /* String */
+                if ( SIZE_NORMAL != size_flag )
+                {
+                    g_warning( "Unexpected size flag near character %"G_GSIZE_FORMAT" in '%s'", (gsize)(ptr - *iter - 1), *iter );
+                    return FALSE;
+                }
                 type_iter->function = parse_string;
                 type = G_TYPE_STRING;
                 break;
 
             case 't':   /* DateTime */
+                if ( SIZE_NORMAL != size_flag )
+                {
+                    g_warning( "Unexpected size flag near character %"G_GSIZE_FORMAT" in '%s'", (gsize)(ptr - *iter - 1), *iter );
+                    return FALSE;
+                }
                 type_iter->function = parse_datetime;
                 type = LSQ_TYPE_DATETIME;
                 break;
@@ -454,15 +515,21 @@ build_parser ( LSQPcreParser *parser, const gchar *parser_string, gchar **parser
                 break;
 
             default:
-                g_return_if_reached();
+                g_warning( "Unexpected type near character %"G_GSIZE_FORMAT" in \'%s\'", (gsize)(ptr - *iter - 1), *iter );
+                return FALSE;
         }
 
-        g_return_if_fail( G_TYPE_INVALID != type );
+        g_return_val_if_fail( G_TYPE_INVALID != type, FALSE );
 
         lsq_parser_set_property_type( LSQ_PARSER( parser ), i, type );
     }
 
-    g_return_if_fail( lsq_parser_n_properties( LSQ_PARSER( parser ) ) == g_strv_length( parser_types ) );
+    if ( lsq_parser_n_properties( LSQ_PARSER( parser ) ) != g_strv_length( parser_types ) )
+    {
+        g_warning( "Parser expression and type list mismatch" );
+        return FALSE;
+    }
+    return TRUE;
 }
 
 static void
@@ -481,6 +548,11 @@ lsq_pcre_parser_parse ( LSQPcreParser *parser, LSQPcreParserContext *ctx )
     int start, end;
     int options = 0;
 
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_PCRE_PARSER( parser ) );
+    g_return_if_fail( LSQ_IS_PCRE_PARSER_CONTEXT( ctx ) );
+#endif
+
     if ( FALSE == lsq_parser_context_get_line( LSQ_PARSER_CONTEXT( ctx ), &line, &line_length ) )
     {
         return;
@@ -496,7 +568,7 @@ lsq_pcre_parser_parse ( LSQPcreParser *parser, LSQPcreParserContext *ctx )
 
 	    /* TODO: use some big buffer to prevent allocation? */
 	    lines = g_strconcat( ctx->lines, line, NULL );
-	    g_free (ctx->lines);
+	    g_free( ctx->lines );
 	    ctx->lines = NULL;
 
 	    g_free( line );
diff --git a/libsqueeze/pcre-parser.h b/libsqueeze/pcre-parser.h
index 61b98a5..3be7dee 100644
--- a/libsqueeze/pcre-parser.h
+++ b/libsqueeze/pcre-parser.h
@@ -21,27 +21,27 @@ G_BEGIN_DECLS
 #define LSQ_TYPE_PCRE_PARSER lsq_pcre_parser_get_type()
 
 #define LSQ_PCRE_PARSER(obj) (		    \
-	G_TYPE_CHECK_INSTANCE_CAST ((obj),  \
-	    LSQ_TYPE_PCRE_PARSER,	    \
-	    LSQPcreParser))
+        G_TYPE_CHECK_INSTANCE_CAST ((obj),  \
+            LSQ_TYPE_PCRE_PARSER,	    \
+            LSQPcreParser))
 
 #define LSQ_IS_PCRE_PARSER(obj) (	    \
-	G_TYPE_CHECK_INSTANCE_TYPE ((obj),  \
-	    LSQ_TYPE_PCRE_PARSER))
+        G_TYPE_CHECK_INSTANCE_TYPE ((obj),  \
+            LSQ_TYPE_PCRE_PARSER))
 
 #define LSQ_PCRE_PARSER_CLASS(klass) (	    \
-	G_TYPE_CHECK_CLASS_CAST ((klass),   \
-	    LSQ_TYPE_PCRE_PARSER,	    \
-	    LSQPcreParserClass))
+        G_TYPE_CHECK_CLASS_CAST ((klass),   \
+            LSQ_TYPE_PCRE_PARSER,	    \
+            LSQPcreParserClass))
 
 #define LSQ_IS_PCRE_PARSER_CLASS(klass) (   \
-	G_TYPE_CHECK_CLASS_TYPE ((klass),   \
-	    LSQ_TYPE_PCRE_PARSER))
+        G_TYPE_CHECK_CLASS_TYPE ((klass),   \
+            LSQ_TYPE_PCRE_PARSER))
 
 #define LSQ_PCRE_PARSER_GET_CLASS(obj) (    \
-	G_TYPE_INSTANCE_GET_CLASS ((obj),   \
-	    LSQ_TYPE_PCRE_PARSER,	    \
-	    LSQPcreParserClass))
+        G_TYPE_INSTANCE_GET_CLASS ((obj),   \
+            LSQ_TYPE_PCRE_PARSER,	    \
+            LSQPcreParserClass))
 
 
 typedef struct _LSQPcreParser LSQPcreParser;
@@ -49,10 +49,13 @@ typedef struct _LSQPcreParser LSQPcreParser;
 typedef struct _LSQPcreParserClass LSQPcreParserClass;
 
 GType
-lsq_pcre_parser_get_type ( void );
+lsq_pcre_parser_get_type ( void ) G_GNUC_CONST;
 
 LSQParser *
-lsq_pcre_parser_new ( const gchar * , gchar ** );
+lsq_pcre_parser_new (
+        const gchar *,
+        gchar **
+    ) G_GNUC_WARN_UNUSED_RESULT;
 
 G_END_DECLS
 
diff --git a/libsqueeze/scanf-parser.c b/libsqueeze/scanf-parser.c
index 873c9af..a700eb5 100644
--- a/libsqueeze/scanf-parser.c
+++ b/libsqueeze/scanf-parser.c
@@ -35,7 +35,7 @@ typedef struct _parse_part parse_part;
 typedef struct _LSQScanfParserContext LSQScanfParserContext;
 typedef struct _LSQScanfParserContextClass LSQScanfParserContextClass;
 
-typedef guint (*LSQParseFunc)(gchar*, guint, parse_part*, LSQScanfParserContext*, LSQScanfParser*);
+typedef guint (*LSQParseFunc)( gchar *, guint, parse_part *, LSQScanfParserContext *, LSQScanfParser * );
 
 struct _parse_part
 {
@@ -72,7 +72,8 @@ struct _LSQScanfParserContextClass
     LSQParserContextClass parent;
 };
 
-GType lsq_scanf_parser_context_get_type(void);
+GType lsq_scanf_parser_context_get_type ( void );
+#define LSQ_IS_SCANF_PARSER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), lsq_scanf_parser_context_get_type()))
 
 struct _LSQScanfParser
 {
@@ -86,48 +87,76 @@ struct _LSQScanfParserClass
     LSQParserClass parent;
 };
 
-G_DEFINE_TYPE(LSQScanfParserContext, lsq_scanf_parser_context, LSQ_TYPE_PARSER_CONTEXT);
+static void
+lsq_scanf_parser_finalize ( GObject *object );
+static void
+parse_part_free ( parse_part *part );
+
+G_DEFINE_TYPE ( LSQScanfParserContext, lsq_scanf_parser_context, LSQ_TYPE_PARSER_CONTEXT );
 
 static void
-lsq_scanf_parser_context_init(LSQScanfParserContext *self)
+lsq_scanf_parser_context_init ( LSQScanfParserContext *self )
 {
 }
 
 static void
-lsq_scanf_parser_context_class_init(LSQScanfParserContextClass *klass)
+lsq_scanf_parser_context_class_init ( LSQScanfParserContextClass *klass )
 {
 }
 
-static LSQParserContext *lsq_scanf_parser_context_new(LSQScanfParser *parser, LSQArchive *archive)
+static LSQParserContext *
+lsq_scanf_parser_context_new ( LSQScanfParser *parser, LSQArchive *archive )
 {
     LSQScanfParserContext *ctx;
     guint n_props;
 
-	ctx = g_object_new(lsq_scanf_parser_context_get_type(), "archive", archive, NULL);
-    n_props = lsq_parser_n_properties(LSQ_PARSER(parser));
-    ctx->data_store = g_new0(union _data_store, n_props);
-    ctx->props_store = g_new0(gpointer, n_props+1);
+    g_return_val_if_fail( LSQ_IS_SCANF_PARSER( parser ), NULL );
+    g_return_val_if_fail( LSQ_IS_ARCHIVE( archive ), NULL );
+
+    ctx = g_object_new( lsq_scanf_parser_context_get_type(), "archive", archive, NULL );
+    n_props = lsq_parser_n_properties( LSQ_PARSER(parser) );
+    ctx->data_store = g_new0( union _data_store, n_props );
+    ctx->props_store = g_new0( gpointer, n_props + 1 );
 
     return LSQ_PARSER_CONTEXT(ctx);
 }
 
-static void build_parser(LSQScanfParser *, const gchar *);
+static gboolean
+build_parser ( LSQScanfParser *, const gchar * );
 
-static void lsq_scanf_parser_parse(LSQScanfParser *, LSQScanfParserContext *);
+static void
+lsq_scanf_parser_parse ( LSQScanfParser *, LSQScanfParserContext * );
 
-G_DEFINE_TYPE(LSQScanfParser, lsq_scanf_parser, LSQ_TYPE_PARSER);
+G_DEFINE_TYPE ( LSQScanfParser, lsq_scanf_parser, LSQ_TYPE_PARSER );
 
 static void
-lsq_scanf_parser_init(LSQScanfParser *self)
+lsq_scanf_parser_init ( LSQScanfParser *self )
 {
 }
 
 static void
-lsq_scanf_parser_class_init(LSQScanfParserClass *klass)
+lsq_scanf_parser_class_init ( LSQScanfParserClass *klass )
 {
     LSQParserClass *parser_class = LSQ_PARSER_CLASS(klass);
-    parser_class->get_context = (LSQParserContext*(*)(LSQParser*,LSQArchive*))lsq_scanf_parser_context_new;
-    parser_class->parse = (void(*)(LSQParser*,LSQParserContext*))lsq_scanf_parser_parse;
+
+    G_OBJECT_CLASS(klass)->finalize = lsq_scanf_parser_finalize;
+
+    parser_class->get_context = (LSQParserContext *(*)(LSQParser *,LSQArchive *))lsq_scanf_parser_context_new;
+    parser_class->parse = (void(*)(LSQParser *,LSQParserContext *))lsq_scanf_parser_parse;
+}
+
+static void
+lsq_scanf_parser_finalize ( GObject *object )
+{
+    LSQScanfParser *parser = LSQ_SCANF_PARSER( object );
+    parse_part *iter, *next;
+
+    for ( iter = parser->parser; NULL != iter; iter = next )
+    {
+        next = iter->next;
+
+        parse_part_free( iter );
+    }
 }
 
 LSQParser *
@@ -135,9 +164,15 @@ lsq_scanf_parser_new ( const gchar *parser_string )
 {
     LSQScanfParser *parser;
 
-    parser = g_object_new(LSQ_TYPE_SCANF_PARSER, NULL);
+    g_return_val_if_fail( NULL != parser_string, NULL );
 
-    build_parser(parser, parser_string);
+    parser = g_object_new( LSQ_TYPE_SCANF_PARSER, NULL );
+
+    if ( FALSE == build_parser( parser, parser_string ) )
+    {
+        g_object_unref( parser );
+        return NULL;
+    }
 
     return LSQ_PARSER(parser);
 }
@@ -149,7 +184,8 @@ skip_byte (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     if ( 1 > lng )
     {
@@ -165,7 +201,8 @@ skip_word (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     if ( 2 > lng )
     {
@@ -181,7 +218,8 @@ skip_dword (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     if ( 4 > lng )
     {
@@ -197,7 +235,8 @@ skip_qword (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     if ( 8 > lng )
     {
@@ -213,7 +252,8 @@ skip_char (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     const gchar *ptr;
     const gchar *delim;
@@ -236,7 +276,7 @@ skip_char (
 
     //for(ptr = str; g_ascii_isspace(*ptr); ptr++);
 
-    ptr = g_strstr_len(str, lng, delim);
+    ptr = g_strstr_len( str + 1, lng - 1, delim );
 
     if ( NULL == ptr )
     {
@@ -252,7 +292,8 @@ skip_decimal (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     gchar *ptr;
 #ifdef DO_EXSTENSIVE_CHECKING
@@ -273,7 +314,7 @@ skip_decimal (
 
     if ( '\0' == delim[0] )
     {
-        g_ascii_strtoll(str, &ptr, 10);
+        g_ascii_strtoll( str, &ptr, 10 );
         return ptr - str;
     }
 
@@ -286,7 +327,7 @@ skip_decimal (
         }
     }
 
-    ptr = g_strstr_len(ptr, lng, delim);
+    ptr = g_strstr_len( ptr, lng, delim );
 
     if ( NULL == ptr )
     {
@@ -294,7 +335,7 @@ skip_decimal (
     }
 
 #ifdef DO_EXSTENSIVE_CHECKING
-    g_ascii_strtoll(str, &ptr2, 10);
+    g_ascii_strtoll( str, &ptr2, 10 );
     if ( ptr > ptr2 )
     {
         return 0;
@@ -310,7 +351,8 @@ skip_floatingpoint (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     gchar *ptr;
 #ifdef DO_EXSTENSIVE_CHECKING
@@ -331,7 +373,7 @@ skip_floatingpoint (
 
     if( '\0' == delim[0] )
     {
-        g_ascii_strtod(str, &ptr);
+        g_ascii_strtod( str, &ptr );
         return ptr - str;
     }
 
@@ -344,14 +386,14 @@ skip_floatingpoint (
         }
     }
 
-    ptr = g_strstr_len(ptr, lng, delim);
+    ptr = g_strstr_len( ptr, lng, delim );
 
     if ( NULL == ptr )
     {
         return 0;
     }
 #ifdef DO_EXSTENSIVE_CHECKING
-    g_ascii_strtod(str, &ptr2);
+    g_ascii_strtod( str, &ptr2 );
     if ( ptr > ptr2 )
     {
         return 0;
@@ -367,7 +409,8 @@ skip_octal (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx ,
-        LSQScanfParser *parser)
+        LSQScanfParser *parser
+    )
 {
     gchar *ptr;
 #ifdef DO_EXSTENSIVE_CHECKING
@@ -388,7 +431,7 @@ skip_octal (
 
     if( '\0' == delim[0] )
     {
-        g_ascii_strtoll(str, &ptr, 010);
+        g_ascii_strtoll( str, &ptr, 010 );
         return ptr - str;
     }
 
@@ -401,7 +444,7 @@ skip_octal (
         }
     }
 
-    ptr = g_strstr_len(ptr, lng, delim);
+    ptr = g_strstr_len( ptr, lng, delim );
 
     if ( NULL == ptr )
     {
@@ -409,7 +452,7 @@ skip_octal (
     }
 
 #ifdef DO_EXSTENSIVE_CHECKING
-    g_ascii_strtoll(str, &ptr2, 010);
+    g_ascii_strtoll( str, &ptr2, 010 );
     if ( ptr > ptr2 )
     {
         return 0;
@@ -425,7 +468,8 @@ skip_string (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     gchar *ptr;
     const gchar *delim;
@@ -441,7 +485,6 @@ skip_string (
         delim = "\n";
     }
 
-
     if ( '\0' == delim[0] )
     {
         return 0;
@@ -456,7 +499,7 @@ skip_string (
         }
     }
 
-    ptr = g_strstr_len ( ptr, lng, delim );
+    ptr = g_strstr_len( ptr, lng, delim );
 
     if ( NULL == ptr )
     {
@@ -472,7 +515,8 @@ skip_datetime (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     gchar *ptr;
     gchar *cur;
@@ -493,7 +537,7 @@ skip_datetime (
     {
     }
 
-    lsq_datetime_from_string(cur, LSQ_PARSER(parser)->datetime_format, &ptr);
+    lsq_datetime_from_string( cur, LSQ_PARSER(parser)->datetime_format, &ptr );
     if ( NULL == ptr )
     {
         return 0;
@@ -523,7 +567,8 @@ skip_unsigned (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     gchar *ptr;
 #ifdef DO_EXSTENSIVE_CHECKING
@@ -544,11 +589,11 @@ skip_unsigned (
 
     if ( '\0' == delim[0] )
     {
-        g_ascii_strtoull ( str, &ptr, 10);
+        g_ascii_strtoull( str, &ptr, 10);
         return ptr - str;
     }
 
-    for ( ptr = str; g_ascii_isspace(*ptr); ++ptr )
+    for ( ptr = str; g_ascii_isspace( *ptr ); ++ptr )
     {
         --lng;
         if ( 0 == lng )
@@ -557,7 +602,7 @@ skip_unsigned (
         }
     }
 
-    ptr = g_strstr_len(ptr, lng, delim);
+    ptr = g_strstr_len( ptr, lng, delim );
 
     if ( NULL == ptr )
     {
@@ -565,7 +610,7 @@ skip_unsigned (
     }
 #ifdef DO_EXSTENSIVE_CHECKING
 
-    g_ascii_strtoull ( str, &ptr2, 10 );
+    g_ascii_strtoull( str, &ptr2, 10 );
 
     if ( ptr > ptr2)
     {
@@ -582,7 +627,8 @@ skip_hexadecimal (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     gchar *ptr;
 #ifdef DO_EXSTENSIVE_CHECKING
@@ -603,11 +649,11 @@ skip_hexadecimal (
 
     if ( '\0' == delim[0] )
     {
-        g_ascii_strtoll ( str, &ptr, 0x10 );
+        g_ascii_strtoll( str, &ptr, 0x10 );
         return ptr - str;
     }
 
-    for ( ptr = str; g_ascii_isspace(*ptr); ++ptr )
+    for ( ptr = str; g_ascii_isspace( *ptr ); ++ptr )
     {
         --lng;
         if ( 0 == lng )
@@ -616,14 +662,14 @@ skip_hexadecimal (
         }
     }
 
-    ptr = g_strstr_len(ptr, lng, delim);
+    ptr = g_strstr_len( ptr, lng, delim );
 
     if ( NULL == ptr )
     {
         return 0;
     }
 #ifdef DO_EXSTENSIVE_CHECKING
-    g_ascii_strtoll ( str, &ptr2, 0x10 );
+    g_ascii_strtoll( str, &ptr2, 0x10 );
     if ( ptr > ptr2 )
     {
         return 0;
@@ -678,7 +724,7 @@ static guint parse_##func(gchar *str, guint lng, parse_part *part, LSQScanfParse
     gchar *ptr;     \
     gchar *ptr2;    \
     type    val;    \
-    type    *pval;    \
+    type  *pval;    \
     const gchar *delim; \
     if(0 == lng) return 0;   \
     delim = part->delimiter; \
@@ -725,10 +771,10 @@ static guint parse_##func(gchar *str, guint lng, parse_part *part, LSQScanfParse
     return ptr - str; \
 }
 
-DEF_PARSE_BIN(byte, 1, gchar, guint, u)
-DEF_PARSE_BIN(word, 2, gushort, guint, u)
-DEF_PARSE_BIN(dword, 4, gulong, gulong, ul)
-DEF_PARSE_BIN(qword, 8, guint64, guint64, ull)
+DEF_PARSE_BIN ( byte, 1, gchar, guint, u )
+DEF_PARSE_BIN ( word, 2, gushort, guint, u )
+DEF_PARSE_BIN ( dword, 4, gulong, gulong, ul )
+DEF_PARSE_BIN ( qword, 8, guint64, guint64, ull )
 
 static guint
 parse_char (
@@ -736,7 +782,8 @@ parse_char (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-	LSQScanfParser *parser )
+	LSQScanfParser *parser
+    )
 {
     const gchar *ptr;
     gchar val;
@@ -766,7 +813,7 @@ parse_char (
 
     //for(ptr = str; g_ascii_isspace(*ptr); ptr++);
 
-    ptr = g_strstr_len(str, lng, delim);
+    ptr = g_strstr_len( str + 1, lng - 1, delim );
 
     if ( NULL == ptr )
     {
@@ -780,18 +827,18 @@ parse_char (
     return ptr - str;
 }
 
-DEF_PARSE_NUM(decimal, 10, gint, gint, i)
-DEF_PARSE_NUM(decimal16, 10, gshort, gint, i)
-DEF_PARSE_NUM(decimal32, 10, glong, glong, l)
-DEF_PARSE_NUM(decimal64, 10, gint64, gint64, ll)
+DEF_PARSE_NUM ( decimal, 10, gint, gint, i )
+DEF_PARSE_NUM ( decimal16, 10, gshort, gint, i )
+DEF_PARSE_NUM ( decimal32, 10, glong, glong, l )
+DEF_PARSE_NUM ( decimal64, 10, gint64, gint64, ll )
 
-DEF_PARSE_FLOAT(floatingpoint, gfloat, f)
-DEF_PARSE_FLOAT(double, gdouble, d)
+DEF_PARSE_FLOAT ( floatingpoint, gfloat, f )
+DEF_PARSE_FLOAT ( double, gdouble, d )
 
-DEF_PARSE_UNS(octal, 010, guint, guint, u)
-DEF_PARSE_UNS(octal16, 010, gushort, guint, u)
-DEF_PARSE_UNS(octal32, 010, gulong, gulong, ul)
-DEF_PARSE_UNS(octal64, 010, guint64, guint64, ull)
+DEF_PARSE_UNS ( octal, 010, guint, guint, u )
+DEF_PARSE_UNS ( octal16, 010, gushort, guint, u )
+DEF_PARSE_UNS ( octal32, 010, gulong, gulong, ul )
+DEF_PARSE_UNS ( octal64, 010, guint64, guint64, ull )
 
 static guint
 parse_string (
@@ -799,14 +846,17 @@ parse_string (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-	LSQScanfParser *parser )
+	LSQScanfParser *parser
+    )
 {
     gchar *ptr;
     gchar *cur;
     const gchar *delim;
 
     if ( 0 == lng )
+    {
         return 0;
+    }
 
     delim = part->delimiter;
     if ( NULL == delim && NULL == part->next )
@@ -824,12 +874,12 @@ parse_string (
         }
     }
 
-    ptr = g_strstr_len(cur, lng, delim);
+    ptr = g_strstr_len( cur, lng, delim );
 
     if ( NULL == ptr )
         return 0;
 
-    ctx->props_store[part->index_] = g_strndup(str, ptr-str);
+    ctx->props_store[part->index_] = g_strndup( str, ptr - str );
 
     return ptr - str;
 }
@@ -840,7 +890,8 @@ parse_datetime (
         guint lng,
         parse_part *part,
         LSQScanfParserContext *ctx,
-        LSQScanfParser *parser )
+        LSQScanfParser *parser
+    )
 {
     gchar *ptr;
     gchar *cur;
@@ -867,7 +918,9 @@ parse_datetime (
 
     *pval = lsq_datetime_from_string( cur, LSQ_PARSER(parser)->datetime_format, &ptr );
     if ( LSQ_DATETIME_NULL == *pval )
+    {
         return 0;
+    }
 
     if ( ( ptr - str ) > lng )
     {
@@ -909,20 +962,28 @@ parse_filename (
     const gchar *delim;
 
     if ( 0 == lng )
+    {
         return 0;
+    }
 
     delim = part->delimiter;
 
     if ( NULL == delim &&  NULL == part->next )
+    {
         delim = "\n";
+    }
 
     if ( '\0' == delim[0] )
+    {
         return 0;
+    }
 
     ptr = g_strstr_len(str, lng, delim);
 
     if ( NULL == ptr )
+    {
         return 0;
+    }
 
     ctx->filename = g_strndup(str, ptr-str);
 
@@ -1031,11 +1092,11 @@ strdup_escaped (/*{{{*/
                         if ( g_ascii_isxdigit( str[i+1] ) )
                         {
                             ++i;
-                            ch = g_ascii_xdigit_value(str[i]);
+                            ch = g_ascii_xdigit_value( str[i] );
                             if ( g_ascii_isxdigit( str[i+1] ) )
                             {
                                 ++i;
-                                ch = (ch*0x10) + g_ascii_xdigit_value( str[i] );
+                                ch = ( ch * 0x10 ) + g_ascii_xdigit_value( str[i] );
                             }
                         }
                     break;
@@ -1047,13 +1108,13 @@ strdup_escaped (/*{{{*/
                             if ( '0' <= str[i+1] && '8' > str[i+1] )
                             {
                                 ++i;
-                                ch = (ch*010) + (str[i]-'0');
+                                ch = ( ch * 010 ) + (str[i]-'0');
                                 if ( 040 > ch )
                                 {
                                     if ( '0' <= str[i+1] && '8' > str[i+1] )
                                     {
                                         ++i;
-                                        ch = (ch*010) + (str[i]-'0');
+                                        ch = ( ch * 010 ) + ( str[i] - '0' );
                                     }
                                 }
                             }
@@ -1068,10 +1129,11 @@ strdup_escaped (/*{{{*/
     return new_str;
 }/*}}}*/
 
-static void
+static gboolean
 build_parser (
         LSQScanfParser *parser,
-        const gchar *parser_string )
+        const gchar *parser_string
+    )
 {
     const gchar *ptr;
     const gchar *cur;
@@ -1087,19 +1149,24 @@ build_parser (
     guint width_flag;
     guint index_flag;
     guint index_;
-
-    parse_part *part = g_new0(parse_part, 1);
-    parse_part *parts = part;
+    parse_part *part;
+    parse_part *parts;
     guint part_count = 0;
 
+    g_return_val_if_fail( LSQ_IS_SCANF_PARSER( parser ), FALSE );
+    g_return_val_if_fail( NULL !=  parser_string, FALSE );
+
+    part = g_new0( parse_part, 1 );
+    parts = part;
+
     cur = ptr = parser_string;
 
     while( '\0' != (ch = *ptr++) )
     {
         if ( '\\' == ch && 'n' == *ptr )
         {
-            part->delimiter = strdup_escaped(cur, ptr-cur);
-            part->next = g_new0(parse_part, 1);
+            part->delimiter = strdup_escaped( cur, ptr - cur );
+            part->next = g_new0( parse_part, 1 );
             part = part->next;
             cur = ++ptr;
             continue;
@@ -1122,16 +1189,16 @@ build_parser (
                 continue;
             }
 
-            part->delimiter = strdup_escaped(cur, ptr-cur-2);
+            part->delimiter = strdup_escaped( cur, ptr - cur - 2 );
 
             /*{{{ check differend index_ %.$*/
             if ( g_ascii_isdigit( ch ) )
             {
-                index_flag = g_ascii_strtoull(ptr-1, &pos, 10);
+                index_flag = g_ascii_strtoull( ptr - 1, &pos, 10 );
                 if ( '$' == *pos )
                 {
                     ptr = pos+1;
-                    index_ = index_flag-1;
+                    index_ = index_flag - 1;
                     ch = *ptr++;
                     if ( '\0' == ch )
                     {
@@ -1146,7 +1213,7 @@ build_parser (
             {
                 skip_flag = TRUE;
                 ch = *ptr++;
-                if ( '\0' == *ptr++ )
+                if ( '\0' == ch )
                 {
                     break;
                 }
@@ -1157,7 +1224,7 @@ build_parser (
             //ignored for now
             if ( g_ascii_isdigit( ch ) )
             {
-                width_flag = g_ascii_strtoull(ptr-1, (gchar **)&ptr, 10);
+                width_flag = g_ascii_strtoull( ptr - 1, (gchar **)&ptr, 10 );
                 ch = *ptr++;
                 if ( '\0' == ch )
                 {
@@ -1195,10 +1262,14 @@ build_parser (
             {
                 /*{{{ byte %b*/
                 case 'b':
-                    g_return_if_fail( 0 == width_flag );
-                    part->next = g_new0(parse_part, 1);
+                    if ( 0 != width_flag )
+                    {
+                        g_warning( "Unexpected %s flag near character %"G_GSIZE_FORMAT" in \'%s\'", "width", (gsize)(ptr - parser_string - 1), parser_string );
+                        return FALSE;
+                    }
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
-                    if ( skip_flag )
+                    if ( TRUE == skip_flag )
                     {
                         switch ( size_flag )
                         {
@@ -1224,19 +1295,19 @@ build_parser (
                         {
                             case SIZE_NORMAL:
                                 part->function = parse_byte;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT );
                             break;
                             case SIZE_SHORT:
                                 part->function = parse_word;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT );
                             break;
                             case SIZE_LONG:
                                 part->function = parse_dword;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_ULONG);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_ULONG );
                             break;
                             case SIZE_LONGLONG:
                                 part->function = parse_qword;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT64);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT64 );
                             break;
                         }
                     }
@@ -1244,10 +1315,14 @@ build_parser (
                 /*}}}*/
                 /*{{{ character %c*/
                 case 'c':
-                    g_return_if_fail( SIZE_NORMAL == size_flag && 0 == width_flag);
-                    part->next = g_new0(parse_part, 1);
+                    if ( SIZE_NORMAL != size_flag || 0 != width_flag )
+                    {
+                        g_warning( "Unexpected %s flag near character %"G_GSIZE_FORMAT" in \'%s\'", ( 0 != width_flag ) ? "width" : "size",  (gsize)(ptr - parser_string - 1), parser_string );
+                        return FALSE;
+                    }
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
-                    if ( skip_flag )
+                    if ( TRUE == skip_flag )
                     {
                         part->function = skip_char;
                     }
@@ -1256,17 +1331,17 @@ build_parser (
                         ++part_count;
                         part->index_ = index_;
                         part->function = parse_char;
-                        lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_CHAR);
+                        lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_CHAR );
                     }
                 break;
                 /*}}}*/
                 /*{{{ decimal %d*/
                 case 'd':
                 case 'i':
-                    part->next = g_new0(parse_part, 1);
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
                     part->width = width_flag;
-                    if ( skip_flag )
+                    if ( TRUE == skip_flag )
                     {
                         part->function = skip_decimal;
                     }
@@ -1278,19 +1353,19 @@ build_parser (
                         {
                             case SIZE_NORMAL:
                                 part->function = parse_decimal;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_INT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_INT );
                             break;
                             case SIZE_SHORT:
                                 part->function = parse_decimal16;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_INT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_INT );
                             break;
                             case SIZE_LONG:
                                 part->function = parse_decimal32;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_LONG);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_LONG );
                             break;
                             case SIZE_LONGLONG:
                                 part->function = parse_decimal64;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_INT64);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_INT64 );
                             break;
                         }
                     }
@@ -1298,11 +1373,15 @@ build_parser (
                 /*}}}*/
                 /*{{{ floating point %f*/
                 case 'f':
-                    g_return_if_fail( SIZE_NORMAL == size_flag || SIZE_LONGLONG == size_flag );
-                    part->next = g_new0(parse_part, 1);
+                    if ( SIZE_NORMAL != size_flag && SIZE_LONGLONG != size_flag )
+                    {
+                        g_warning( "Unexpected %s flag near character %"G_GSIZE_FORMAT" in \'%s\'", "size",  (gsize)(ptr - parser_string - 1), parser_string );
+                        return FALSE;
+                    }
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
                     part->width = width_flag;
-                    if ( skip_flag )
+                    if ( TRUE == skip_flag )
                     {
                         part->function = skip_floatingpoint;
                     }
@@ -1314,11 +1393,11 @@ build_parser (
                         {
                             case SIZE_NORMAL:
                                 part->function = parse_floatingpoint;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_FLOAT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_FLOAT );
                             break;
                             case SIZE_LONGLONG:
                                 part->function = parse_double;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_DOUBLE);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_DOUBLE );
                             break;
                             default:
                             break;
@@ -1328,10 +1407,10 @@ build_parser (
                 /*}}}*/
                 /*{{{ octal %o*/
                 case 'o':
-                    part->next = g_new0(parse_part, 1);
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
                     part->width = width_flag;
-                    if ( skip_flag )
+                    if ( TRUE == skip_flag )
                     {
                         part->function = skip_octal;
                     }
@@ -1343,19 +1422,19 @@ build_parser (
                         {
                             case SIZE_NORMAL:
                                 part->function = parse_octal;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT );
                             break;
                             case SIZE_SHORT:
                                 part->function = parse_octal16;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT );
                             break;
                             case SIZE_LONG:
                                 part->function = parse_octal32;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_ULONG);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_ULONG );
                             break;
                             case SIZE_LONGLONG:
                                 part->function = parse_octal64;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT64);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT64 );
                             break;
                         }
                     }
@@ -1363,11 +1442,15 @@ build_parser (
                 /*}}}*/
                 /*{{{ string %s*/
                 case 's':
-                    g_return_if_fail( SIZE_NORMAL == size_flag );
-                    part->next = g_new0(parse_part, 1);
+                    if ( SIZE_NORMAL != size_flag )
+                    {
+                        g_warning( "Unexpected %s flag near character %"G_GSIZE_FORMAT" in \'%s\'", "size",  (gsize)(ptr - parser_string - 1), parser_string );
+                        return FALSE;
+                    }
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
                     part->width = width_flag;
-                    if ( skip_flag )
+                    if ( TRUE == skip_flag )
                     {
                         part->function = skip_string;
                     }
@@ -1376,17 +1459,21 @@ build_parser (
                         ++part_count;
                         part->index_ = index_;
                         part->function = parse_string;
-                        lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_STRING);
+                        lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_STRING );
                     }
                 break;
                 /*}}}*/
                 /*{{{ datetime %t*/
                 case 't':
-                    g_return_if_fail(!size_flag);
-                    part->next = g_new0(parse_part, 1);
+                    if ( SIZE_NORMAL != size_flag )
+                    {
+                        g_warning( "Unexpected %s flag near character %"G_GSIZE_FORMAT" in \'%s\'", "size",  (gsize)(ptr - parser_string - 1), parser_string );
+                        return FALSE;
+                    }
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
                     part->width = width_flag;
-                    if(skip_flag)
+                    if ( TRUE == skip_flag )
                     {
                         part->function = skip_datetime;
                     }
@@ -1395,16 +1482,16 @@ build_parser (
                         part_count++;
                         part->index_ = index_;
                         part->function = parse_datetime;
-                        lsq_parser_set_property_type(LSQ_PARSER(parser), index_, LSQ_TYPE_DATETIME);
+                        lsq_parser_set_property_type( LSQ_PARSER(parser), index_, LSQ_TYPE_DATETIME );
                     }
                 break;
                 /*}}}*/
                 /*{{{ unsigned decimal %u*/
                 case 'u':
-                    part->next = g_new0(parse_part, 1);
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
                     part->width = width_flag;
-                    if ( skip_flag )
+                    if ( TRUE == skip_flag )
                     {
                         part->function = skip_unsigned;
                     }
@@ -1416,19 +1503,19 @@ build_parser (
                         {
                             case SIZE_NORMAL:
                                 part->function = parse_unsigned;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT );
                             break;
                             case SIZE_SHORT:
                                 part->function = parse_unsigned16;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT );
                             break;
                             case SIZE_LONG:
                                 part->function = parse_unsigned32;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_ULONG);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_ULONG );
                             break;
                             case SIZE_LONGLONG:
                                 part->function = parse_unsigned64;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT64);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT64 );
                             break;
                         }
                     }
@@ -1437,10 +1524,10 @@ build_parser (
                 /*{{{ hexadecimal %x %X*/
                 case 'x':
                 case 'X':
-                    part->next = g_new0(parse_part, 1);
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
                     part->width = width_flag;
-                    if ( skip_flag )
+                    if ( TRUE == skip_flag )
                     {
                         part->function = skip_hexadecimal;
                     }
@@ -1452,19 +1539,19 @@ build_parser (
                         {
                             case SIZE_NORMAL:
                                 part->function = parse_hexadecimal;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT );
                             break;
                             case SIZE_SHORT:
                                 part->function = parse_hexadecimal16;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT );
                             break;
                             case SIZE_LONG:
                                 part->function = parse_hexadecimal32;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_ULONG);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_ULONG );
                             break;
                             case SIZE_LONGLONG:
                                 part->function = parse_hexadecimal64;
-                                lsq_parser_set_property_type(LSQ_PARSER(parser), index_, G_TYPE_UINT64);
+                                lsq_parser_set_property_type( LSQ_PARSER(parser), index_, G_TYPE_UINT64 );
                             break;
                         }
                     }
@@ -1472,31 +1559,55 @@ build_parser (
                 /*}}}*/
                 /*{{{ filename %F*/
                 case 'F':
-                    g_return_if_fail( FALSE == skip_flag && SIZE_NORMAL == size_flag && 0 == width_flag);
-                    part->next = g_new0(parse_part, 1);
+                    if ( TRUE == skip_flag || SIZE_NORMAL != size_flag || 0 != width_flag)
+                    {
+                        g_warning( "Unexpected %s flag near character %"G_GSIZE_FORMAT" in \'%s\'", ( FALSE == skip_flag ) ? ( 0 != width_flag ) ? "width" : "size" : "skip",  (gsize)(ptr - parser_string - 1), parser_string );
+                        return FALSE;
+                    }
+                    part->next = g_new0( parse_part, 1 );
                     part = part->next;
                     part->function = parse_filename;
                 break;
                 /*}}}*/
                 default:
-                    g_return_if_reached();
+                    g_warning( "Unexpected type near character %"G_GSIZE_FORMAT" in \'%s\'", (gsize)(ptr - parser_string - 1), parser_string );
+                    return FALSE;
             }
             cur = ptr;
         }
     }
 
     parser->parser = parts;
+
+    return TRUE;
+}
+
+static void
+parse_part_free ( parse_part *part )
+{
+    g_return_if_fail( NULL != part );
+
+    g_free( part->delimiter );
+
+    g_free( part );
 }
 
 static void
 lsq_scanf_parser_parse (
         LSQScanfParser *parser,
-        LSQScanfParserContext *ctx )
+        LSQScanfParserContext *ctx
+    )
 {
     gchar *line, *ptr;
     gsize line_length, lng;
     guint size, line_nr;
     parse_part *part;
+
+#ifdef DEBUG
+    g_return_if_fail( LSQ_IS_SCANF_PARSER( parser ) );
+    g_return_if_fail( LSQ_IS_SCANF_PARSER_CONTEXT( ctx ) );
+#endif
+
     if ( FALSE == lsq_parser_context_get_line( LSQ_PARSER_CONTEXT(ctx), &line, &line_length ) )
     {
         return;
@@ -1518,11 +1629,11 @@ lsq_scanf_parser_parse (
         //parse
         if ( NULL != part->function )
         {
-            size = part->function(ptr, lng, part, ctx, parser);
+            size = part->function( ptr, lng, part, ctx, parser );
             if ( 0 == size )
             {
                 //no match
-                if(line_nr)
+                if ( 0 != line_nr )
                 {
                     ptr = line;
                     lng = line_length;
@@ -1532,7 +1643,7 @@ lsq_scanf_parser_parse (
                 }
                 ctx->parse_loc = parser->parser;
                 ctx->parse_line = 0;
-                g_free(line);
+                g_free( line );
                 return;
             }
             ptr += size;
@@ -1541,7 +1652,7 @@ lsq_scanf_parser_parse (
 
         if ( NULL != part->delimiter )
         {
-            if ( !g_str_has_prefix( ptr, part->delimiter ) )
+            if ( FALSE == g_str_has_prefix( ptr, part->delimiter ) )
             {
                 //no match
                 if ( 0 != line_nr )
@@ -1554,27 +1665,29 @@ lsq_scanf_parser_parse (
                 }
                 ctx->parse_loc = parser->parser;
                 ctx->parse_line = 0;
-                g_free(line);
+                g_free( line );
                 return;
             }
 
             size = strlen(part->delimiter);
             if ( size > lng )
+            {
                 size = lng;
+            }
             ptr += size;
             lng -= size;
         }
 
         if ( NULL != part->delimiter )
         {
-            if ( g_str_has_suffix( part->delimiter, "\n" ) )
+            if ( TRUE == g_str_has_suffix( part->delimiter, "\n" ) )
             {
                 //next line
                 if ( NULL != part->next )
                 {
                     ctx->parse_loc = part->next;
-                    ctx->parse_line = line_nr+1;
-                    g_free(line);
+                    ctx->parse_line = line_nr + 1;
+                    g_free( line );
                     return;
                 }
             }
@@ -1583,13 +1696,13 @@ lsq_scanf_parser_parse (
         part = part->next;
     }
 
-    g_free(line);
+    g_free( line );
 
     if ( NULL == part )
     {
-        LSQArchiveIter *iter = lsq_archive_add_file(LSQ_PARSER_CONTEXT(ctx)->archive, ctx->filename);
-        lsq_archive_iter_set_propsv(iter, ctx->props_store);
-        lsq_archive_iter_unref(iter);
+        LSQArchiveIter *iter = lsq_archive_add_file( LSQ_PARSER_CONTEXT(ctx)->archive, ctx->filename );
+        lsq_archive_iter_set_propsv( iter, ctx->props_store );
+        lsq_archive_iter_unref( iter );
 
         ctx->parse_loc = parser->parser;
         ctx->parse_line = 0;
diff --git a/libsqueeze/scanf-parser.h b/libsqueeze/scanf-parser.h
index bca43e3..3e19a7c 100644
--- a/libsqueeze/scanf-parser.h
+++ b/libsqueeze/scanf-parser.h
@@ -20,28 +20,28 @@ G_BEGIN_DECLS
 
 #define LSQ_TYPE_SCANF_PARSER lsq_scanf_parser_get_type()
 
-#define LSQ_SCANF_PARSER(obj) (			   \
-		G_TYPE_CHECK_INSTANCE_CAST ((obj),  \
-			LSQ_TYPE_SCANF_PARSER,				  \
-			LSQScanfParser))
+#define LSQ_SCANF_PARSER(obj) ( \
+        G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+            LSQ_TYPE_SCANF_PARSER, \
+            LSQScanfParser))
 
-#define LSQ_IS_SCANF_PARSER(obj) (			\
-		G_TYPE_CHECK_INSTANCE_TYPE ((obj),  \
-			LSQ_TYPE_SCANF_PARSER))
+#define LSQ_IS_SCANF_PARSER(obj) ( \
+        G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+            LSQ_TYPE_SCANF_PARSER))
 
-#define LSQ_SCANF_PARSER_CLASS(class) (	  \
-		G_TYPE_CHECK_CLASS_CAST ((class),  \
-			LSQ_TYPE_SCANF_PARSER,				 \
-			LSQScanfParserClass))
+#define LSQ_SCANF_PARSER_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_CAST ((klass), \
+            LSQ_TYPE_SCANF_PARSER, \
+            LSQScanfParserClass))
 
-#define LSQ_IS_SCANF_PARSER_CLASS(class) (   \
-		G_TYPE_CHECK_CLASS_TYPE ((class),  \
-			LSQ_TYPE_SCANF_PARSER))
+#define LSQ_IS_SCANF_PARSER_CLASS(klass) ( \
+        G_TYPE_CHECK_CLASS_TYPE ((klass), \
+            LSQ_TYPE_SCANF_PARSER))
 
-#define LSQ_SCANF_PARSER_GET_CLASS(obj) (	\
-		G_TYPE_INSTANCE_GET_CLASS ((obj),  \
-			LSQ_TYPE_SCANF_PARSER,				 \
-	  LSQScanfParserClass))
+#define LSQ_SCANF_PARSER_GET_CLASS(obj) ( \
+        G_TYPE_INSTANCE_GET_CLASS ((obj), \
+            LSQ_TYPE_SCANF_PARSER, \
+            LSQScanfParserClass))
 
 
 typedef struct _LSQScanfParser LSQScanfParser;
@@ -49,10 +49,10 @@ typedef struct _LSQScanfParser LSQScanfParser;
 typedef struct _LSQScanfParserClass LSQScanfParserClass;
 
 GType
-lsq_scanf_parser_get_type ( void );
+lsq_scanf_parser_get_type ( void ) G_GNUC_CONST;
 
 LSQParser *
-lsq_scanf_parser_new ( const gchar * );
+lsq_scanf_parser_new ( const gchar * ) G_GNUC_WARN_UNUSED_RESULT;
 
 G_END_DECLS
 
diff --git a/libsqueeze/support-factory.c b/libsqueeze/support-factory.c
index 6d9f631..1ae93b5 100644
--- a/libsqueeze/support-factory.c
+++ b/libsqueeze/support-factory.c
@@ -34,105 +34,69 @@
 #include "internals.h"
 
 static void
-lsq_support_factory_class_init(LSQSupportFactoryClass *);
-static void
-lsq_support_factory_init(LSQSupportFactory *);
-static void
-lsq_support_factory_dispose(GObject *object);
-static void
-lsq_support_factory_finalize(GObject *object);
+lsq_support_factory_finalize ( GObject *object );
 
-static GObjectClass *parent_class;
-
-GType
-lsq_support_factory_get_type (void)
-{
-	static GType lsq_support_factory_type = 0;
-
-	if (!lsq_support_factory_type)
-	{
-		static const GTypeInfo lsq_support_factory_info = 
-		{
-			sizeof (LSQSupportFactoryClass),
-			(GBaseInitFunc) NULL,
-			(GBaseFinalizeFunc) NULL,
-			(GClassInitFunc) lsq_support_factory_class_init,
-			(GClassFinalizeFunc) NULL,
-			NULL,
-			sizeof (LSQSupportFactory),
-			0,
-			(GInstanceInitFunc) lsq_support_factory_init,
-			NULL
-		};
-
-		lsq_support_factory_type = g_type_register_static (G_TYPE_OBJECT, "LSQSupportFactory", &lsq_support_factory_info, 0);
-	}
-	return lsq_support_factory_type;
-}
+G_DEFINE_TYPE ( LSQSupportFactory, lsq_support_factory, G_TYPE_OBJECT );
 
 static void
-lsq_support_factory_class_init(LSQSupportFactoryClass *support_factory_class)
+lsq_support_factory_class_init ( LSQSupportFactoryClass *support_factory_class )
 {
-	GObjectClass *object_class = G_OBJECT_CLASS(support_factory_class);
-
-	object_class->dispose = lsq_support_factory_dispose;
-	object_class->finalize = lsq_support_factory_finalize;
-
-	parent_class = g_type_class_peek(G_TYPE_OBJECT); 
+    GObjectClass *object_class = G_OBJECT_CLASS(support_factory_class);
 
+    object_class->finalize = lsq_support_factory_finalize;
 }
 
 static void
-lsq_support_factory_init(LSQSupportFactory *support_factory)
+lsq_support_factory_init ( LSQSupportFactory *support_factory )
 {
 }
 
 /**
- * lsq_support_factory_dispose:
+ * lsq_support_factory_finalize:
  *
  * @object: LSQSupportFactory object
  *
  */
 static void
-lsq_support_factory_dispose(GObject *object)
+lsq_support_factory_finalize ( GObject *object )
 {
+    LSQSupportFactory *factory = LSQ_SUPPORT_FACTORY(object);
 
-	parent_class->dispose(object);
-}
+    g_free( factory->filename );
+    g_free( factory->id );
+    g_slist_free( factory->mime_support );
 
-/**
- * lsq_support_factory_finalize:
- *
- * @object: LSQSupportFactory object
- *
- */
-static void
-lsq_support_factory_finalize(GObject *object)
-{
-	parent_class->finalize(object);
+    G_OBJECT_CLASS(lsq_support_factory_parent_class)->finalize( object );
 }
 
 static gint
-lsq_lookup_mime_support(gconstpointer a, gconstpointer b)
+lsq_lookup_mime_support ( gconstpointer a, gconstpointer b )
 {
-	return 1;
+    return 1;
 }
 
 void
-lsq_support_factory_add_template(LSQSupportFactory *factory, LSQSupportTemplate *s_template)
+lsq_support_factory_add_template ( LSQSupportFactory *factory, LSQSupportTemplate *s_template )
 {
-	GSList *result = g_slist_find_custom(lsq_mime_support_list, s_template, lsq_lookup_mime_support);
-	if(!result)
-	{
-		factory->mime_support = g_slist_prepend(factory->mime_support, s_template);
-		lsq_mime_support_list = g_slist_prepend(lsq_mime_support_list, s_template);
-	}
-
+    GSList *result;
+   
+    g_return_if_fail( LSQ_IS_SUPPORT_FACTORY( factory ) );
+    g_return_if_fail( NULL != s_template );
+
+    result = g_slist_find_custom( lsq_mime_support_list, s_template, lsq_lookup_mime_support );
+    if ( NULL == result )
+    {
+        factory->mime_support = g_slist_prepend( factory->mime_support, s_template );
+        lsq_mime_support_list = g_slist_prepend( lsq_mime_support_list, s_template );
+    }
 }
 
 gint
-lsq_suport_factory_compare_filename(const LSQSupportFactory *factory, const gchar *filename)
+lsq_suport_factory_compare_filename ( const LSQSupportFactory *factory, const gchar *filename )
 {
-  return strcmp(factory->filename, filename);
+    g_return_val_if_fail( LSQ_IS_SUPPORT_FACTORY( factory ), 1 );
+    g_return_val_if_fail( NULL != filename, 1 );
+
+    return strcmp( factory->filename, filename );
 }
 
diff --git a/libsqueeze/support-factory.h b/libsqueeze/support-factory.h
index 2d10d83..63fc87c 100644
--- a/libsqueeze/support-factory.h
+++ b/libsqueeze/support-factory.h
@@ -3,45 +3,58 @@
 
 #define LSQ_TYPE_SUPPORT_FACTORY lsq_support_factory_get_type()
 
-#define LSQ_SUPPORT_FACTORY(obj)		 ( \
-		G_TYPE_CHECK_INSTANCE_CAST ((obj),	\
-			LSQ_TYPE_SUPPORT_FACTORY,	  \
-			LSQSupportFactory))
+#define LSQ_SUPPORT_FACTORY(obj) ( \
+        G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+            LSQ_TYPE_SUPPORT_FACTORY, \
+            LSQSupportFactory))
 
-#define LSQ_IS_SUPPORT_FACTORY(obj)	  ( \
-		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
-			LSQ_TYPE_SUPPORT_FACTORY))
+#define LSQ_IS_SUPPORT_FACTORY(obj) ( \
+        G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+            LSQ_TYPE_SUPPORT_FACTORY))
 
 #define LSQ_SUPPORT_FACTORY_CLASS(klass) ( \
-		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
-			LSQ_TYPE_SUPPORT_FACTORY,	  \
-			LSQSupportFactoryClass))
+        G_TYPE_CHECK_CLASS_CAST ((klass), \
+            LSQ_TYPE_SUPPORT_FACTORY, \
+            LSQSupportFactoryClass))
 
 #define LSQ_IS_SUPPORT_FACTORY_CLASS(klass) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
-			LSQ_TYPE_SUPPORT_FACTORY))
+        G_TYPE_CHECK_CLASS_TYPE ((klass), \
+            LSQ_TYPE_SUPPORT_FACTORY))
 
 
 typedef struct _LSQSupportFactory LSQSupportFactory;
 
 struct _LSQSupportFactory
 {
-	GObject		  parent;
-	gchar		   *filename;
-	gchar		   *id;
-	GSList		  *mime_support;
+    GObject parent;
+    gchar *filename;
+    gchar *id;
+    GSList *mime_support;
 };
 
 typedef struct _LSQSupportFactoryClass LSQSupportFactoryClass;
 
 struct _LSQSupportFactoryClass
 {
-	GObjectClass parent;
+    GObjectClass parent;
 };
 
-GType				lsq_support_factory_get_type(void);
-void				 lsq_support_factory_init_archive(LSQSupportFactory *builder, LSQArchive *archive);
-void				 lsq_support_factory_add_template(LSQSupportFactory *factory, LSQSupportTemplate *s_template);
-gint lsq_suport_factory_compare_filename(const LSQSupportFactory *factory, const gchar *filename);
+GType
+lsq_support_factory_get_type ( void ) G_GNUC_CONST;
+void
+lsq_support_factory_init_archive (
+        LSQSupportFactory *builder,
+        LSQArchive *archive
+    );
+void
+lsq_support_factory_add_template (
+        LSQSupportFactory *factory,
+        LSQSupportTemplate *s_template
+    );
+gint
+lsq_suport_factory_compare_filename (
+        const LSQSupportFactory *factory,
+        const gchar *filename
+    ) G_GNUC_PURE;
 
 #endif /* __LIBSQUEEZE_SUPPORT_FACTORY_H__ */
diff --git a/libsqueeze/support-reader.c b/libsqueeze/support-reader.c
index 7430f62..7d40535 100644
--- a/libsqueeze/support-reader.c
+++ b/libsqueeze/support-reader.c
@@ -40,82 +40,6 @@
 
 #include "internals.h"
 
-static void
-lsq_support_reader_class_init(LSQSupportReaderClass *);
-static void
-lsq_support_reader_init(LSQSupportReader *);
-static void
-lsq_support_reader_dispose(GObject *object);
-static void
-lsq_support_reader_finalize(GObject *object);
-
-static GObjectClass *parent_class;
-
-GType
-lsq_support_reader_get_type (void)
-{
-	static GType lsq_support_reader_type = 0;
-
- 	if (!lsq_support_reader_type)
-	{
- 		static const GTypeInfo lsq_support_reader_info = 
-		{
-			sizeof (LSQSupportReaderClass),
-			(GBaseInitFunc) NULL,
-			(GBaseFinalizeFunc) NULL,
-			(GClassInitFunc) lsq_support_reader_class_init,
-			(GClassFinalizeFunc) NULL,
-			NULL,
-			sizeof (LSQSupportReader),
-			0,
-			(GInstanceInitFunc) lsq_support_reader_init,
-			NULL
-		};
-
-		lsq_support_reader_type = g_type_register_static (G_TYPE_OBJECT, "LSQSupportReader", &lsq_support_reader_info, 0);
-	}
-	return lsq_support_reader_type;
-}
-
-static void
-lsq_support_reader_class_init(LSQSupportReaderClass *support_reader_class)
-{
-	GObjectClass *object_class = G_OBJECT_CLASS(support_reader_class);
-
-	object_class->dispose = lsq_support_reader_dispose;
-	object_class->finalize = lsq_support_reader_finalize;
-	
-	parent_class = g_type_class_peek(G_TYPE_OBJECT); 
-}
-
-static void
-lsq_support_reader_init(LSQSupportReader *support)
-{
-
-}
-
-static void
-lsq_support_reader_dispose(GObject *object)
-{
-
-}
-
-static void
-lsq_support_reader_finalize(GObject *object)
-{
-
-}
-
-LSQSupportReader *
-lsq_support_reader_new(void)
-{
-	LSQSupportReader *reader;
-
-	reader = g_object_new(LSQ_TYPE_SUPPORT_READER, NULL);
-
-	return reader;
-}
-
 /**
  * lsq_support_reader_parse_file:
  *
@@ -124,204 +48,291 @@ lsq_support_reader_new(void)
  * Returns: a new LSQSupportFactory object.
  */
 LSQSupportFactory *
-lsq_support_reader_parse_file(const gchar *filename)
+lsq_support_reader_parse_file ( const gchar *filename )
 {
-	gint i = 0;
-	LSQSupportFactory *factory = g_object_new(LSQ_TYPE_SUPPORT_FACTORY, NULL);
-	const gchar *type, *name;
-	gchar **mime_types;
-	LSQCommandOption **add_options = NULL;
-	LSQCommandOption **remove_options = NULL;
-	LSQCommandOption **extract_options = NULL;
-	gchar **option_names;
-	gchar **column_names;
-	LSQParser *parser = NULL;
-	const gchar *parser_string;
-	const gchar *parser_regex;
-	const gchar *parser_datetime;
-	gchar **_mime_types;
+    gint i = 0;
+    LSQSupportFactory *factory;
+    const gchar *type, *name;
+    gchar **mime_types;
+    LSQCommandOption **add_options = NULL;
+    LSQCommandOption **remove_options = NULL;
+    LSQCommandOption **extract_options = NULL;
+    gchar **option_names;
+    gchar **column_names;
+    LSQParser *parser = NULL;
+    const gchar *parser_string;
+    const gchar *parser_regex;
+    const gchar *parser_datetime;
+    gchar **_mime_types;
 #ifdef HAVE_PCRE
-	gchar **regex_types;
+    gchar **regex_types;
 #endif
+    XfceRc *rc;
 
-	XfceRc *rc = xfce_rc_simple_open(filename, TRUE);
+    g_return_val_if_fail( NULL != filename, NULL );
+
+    rc = xfce_rc_simple_open( filename, TRUE );
+    if ( NULL == rc )
+    {
+        g_warning( "Unable to open %s", filename );
+        return NULL;
+    }
 
-	factory->filename = g_path_get_basename(filename);
+    factory = g_object_new( LSQ_TYPE_SUPPORT_FACTORY, NULL );
 
-	xfce_rc_set_group(rc, "Desktop Entry");
+    factory->filename = g_path_get_basename( filename );
 
-	type = xfce_rc_read_entry(rc, "Type", "");
-	if (0 != strcmp(type, "X-Squeeze-Archiver"))
-	{
-		g_object_unref(factory);
-		return NULL;
-	}
+    xfce_rc_set_group( rc, "Desktop Entry" );
 
-	name = xfce_rc_read_entry(rc, "Name", NULL);
-	if (NULL != name)
+    type = xfce_rc_read_entry( rc, "Type", "" );
+    if ( 0 != strcmp( type, "X-Squeeze-Archiver" ) )
     {
-		factory->id = g_strdup(name);
+        g_warning( "%s is not a Squeeze support file", filename );
+        g_object_unref( factory );
+        return NULL;
     }
-	else
-	{
-		g_object_unref(factory);
-		return NULL;
-	}
 
-	mime_types = xfce_rc_read_list_entry(rc, "MimeType", ";");
+    name = xfce_rc_read_entry( rc, "Name", NULL );
+    if ( NULL != name )
+    {
+        factory->id = g_strdup( name );
+    }
+    else
+    {
+        g_warning( "Missing %s in %s", "Name", filename );
+        g_object_unref( factory );
+        return NULL;
+    }
 
-	xfce_rc_set_group(rc, "Squeeze-Add");
+    mime_types = xfce_rc_read_list_entry( rc, "MimeType", ";" );
+    if ( NULL == mime_types )
+    {
+        g_warning( "Missing %s in %s", "MimeType", filename );
+        g_object_unref( factory );
+        return NULL;
+    }
 
-	option_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Options", ";");
+    xfce_rc_set_group( rc, "Squeeze-Add" );
 
-	if(NULL != option_names)
-	{
-        add_options = lsq_command_option_create_list(rc, option_names);
-        g_strfreev(option_names);
-	}
+    option_names = xfce_rc_read_list_entry( rc, "X-Squeeze-Options", ";" );
 
-	xfce_rc_set_group(rc, "Squeeze-Remove");
+    if ( NULL != option_names )
+    {
+        add_options = lsq_command_option_create_list( rc, option_names );
+        g_strfreev( option_names );
+    }
 
-	option_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Options", ";");
+    xfce_rc_set_group( rc, "Squeeze-Remove" );
 
-	if (NULL != option_names)
-	{
-        remove_options = lsq_command_option_create_list(rc, option_names);
-        g_strfreev (option_names);
-	}
+    option_names = xfce_rc_read_list_entry( rc, "X-Squeeze-Options", ";" );
+
+    if ( NULL != option_names )
+    {
+        remove_options = lsq_command_option_create_list (rc, option_names );
+        g_strfreev( option_names );
+    }
 
-	xfce_rc_set_group(rc, "Squeeze-Extract");
+    xfce_rc_set_group( rc, "Squeeze-Extract" );
 
-	option_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Options", ";");
-	if(option_names)
-	{
-        extract_options = lsq_command_option_create_list(rc, option_names);
-        g_strfreev(option_names);
-	}
+    option_names = xfce_rc_read_list_entry( rc, "X-Squeeze-Options", ";" );
+    if ( NULL != option_names )
+    {
+        extract_options = lsq_command_option_create_list( rc, option_names );
+        g_strfreev( option_names );
+    }
 
-	xfce_rc_set_group(rc, "Squeeze-Refresh");
-	column_names = xfce_rc_read_list_entry(rc, "X-Squeeze-Headers", ";");
-	parser_string = xfce_rc_read_entry(rc, "X-Squeeze-Parse", NULL);
-	parser_regex = xfce_rc_read_entry(rc, "X-Squeeze-Parse-Regex", NULL);
-	parser_datetime = xfce_rc_read_entry(rc, "X-Squeeze-Parse-DateTime", NULL);
+    xfce_rc_set_group( rc, "Squeeze-Refresh" );
+    column_names = xfce_rc_read_list_entry( rc, "X-Squeeze-Headers", ";" );
 
-	if (NULL != parser_string)
-	{
-	    parser = lsq_scanf_parser_new(parser_string);
-	}
+    if ( NULL == column_names )
+    {
+        g_warning( "Missing %s in %s", "X-Squeeze-Headers", filename );
+        g_object_unref( factory );
+        return NULL;
+    }
+
+    parser_string = xfce_rc_read_entry( rc, "X-Squeeze-Parse", NULL );
+    parser_regex = xfce_rc_read_entry( rc, "X-Squeeze-Parse-Regex", NULL );
+    parser_datetime = xfce_rc_read_entry( rc, "X-Squeeze-Parse-DateTime", NULL );
+
+    if ( NULL != parser_string )
+    {
+        parser = lsq_scanf_parser_new( parser_string );
+        if ( NULL == parser )
+        {
+            g_warning( "Unable to parse %s in %s", "X-Squeeze-Parse", filename );
+            g_object_unref( factory );
+            return NULL;
+        }
+    }
 #ifdef HAVE_PCRE
-	else if ( NULL != parser_regex )
-	{
-	    regex_types = xfce_rc_read_list_entry(rc, "X-Squeeze-Types", ";");
-	    parser = lsq_pcre_parser_new( parser_regex, regex_types );
-	    g_strfreev( regex_types );
-	}
+    else if ( NULL != parser_regex )
+    {
+        regex_types = xfce_rc_read_list_entry( rc, "X-Squeeze-Types", ";" );
+        if ( NULL == regex_types )
+        {
+            g_warning( "Missing %s in %s", "X-Squeeze-Types", filename );
+            g_object_unref( factory );
+            return NULL;
+        }
+        parser = lsq_pcre_parser_new( parser_regex, regex_types );
+        g_strfreev( regex_types );
+        if ( NULL == parser )
+        {
+            g_warning( "Unable to parse %s in %s", "X-Squeeze-Parse-Regex", filename );
+            g_object_unref( factory );
+            return NULL;
+        }
+    }
 #endif
-        if ( NULL != parser_datetime )
+    else
+    {
+        g_warning( "Missing %s in %s", "X-Squeeze-Parse", filename );
+        g_object_unref( factory );
+        return NULL;
+    }
+
+    if ( NULL != parser_datetime )
+    {
+        lsq_parser_set_datetime_format( parser, parser_datetime );
+    }
+
+    if ( lsq_parser_n_properties( parser ) != g_strv_length( column_names ) )
+    {
+        g_warning( "Parser expression and %s mismatch in %s", "X-Squeeze-Headers", filename );
+        g_object_unref( factory );
+        return NULL;
+    }
+
+    _mime_types = mime_types;
+    for ( i = 0; NULL != _mime_types[i]; ++i )
+    {
+        LSQSupportTemplate *s_template = g_new( LSQSupportTemplate, 1 );
+        const gchar *new_str_queue;
+        const gchar *add_str_queue;
+        const gchar *remove_str_queue;
+        const gchar *extract_str_queue;
+        const gchar *refresh_str_queue;
+
+        xfce_rc_set_group( rc, _mime_types[i] );
+        /* only add to builder->mime_types if all req. apps are found */
+        s_template->required_apps = xfce_rc_read_list_entry( rc, "X-Squeeze-Requires", ";" );
+        if ( NULL != s_template->required_apps )
+        {
+            gchar **_iter;
+            s_template->supported = TRUE;
+            for ( _iter = s_template->required_apps; NULL != *_iter; ++_iter )
+            {
+                gchar *path = g_find_program_in_path( *_iter );
+                if ( NULL != path )
+                {
+                    g_free( path );
+                }
+                else
+                {
+                    s_template->supported = FALSE;
+                    break;
+                }
+            }
+        }
+        else
         {
-            lsq_parser_set_datetime_format( parser, parser_datetime );
+            s_template->supported = FALSE;
         }
 
-	_mime_types = mime_types;
-	for(i = 0; _mime_types[i]; ++i)
-	{
-		LSQSupportTemplate *s_template = g_new(LSQSupportTemplate, 1);
-		const gchar *new_str_queue;
-		const gchar *add_str_queue;
-		const gchar *remove_str_queue;
-		const gchar *extract_str_queue;
-		const gchar *refresh_str_queue;
-
-		xfce_rc_set_group(rc, _mime_types[i]);
-		/* only add to builder->mime_types if all req. apps are found */
-		s_template->required_apps = xfce_rc_read_list_entry(rc, "X-Squeeze-Requires", ";");
-		if (s_template->required_apps)
-		{
-			gchar **_iter = s_template->required_apps;
-			s_template->supported = TRUE;
-			while(*_iter)
-			{
-				gchar *path = g_find_program_in_path(*_iter);
-				if(path)
-				{
-					g_free(path);
-				}
-				else
-				{
-					s_template->supported = FALSE;
-					break;
-				}
-				_iter++;
-			}
-		}
-	 	else
-		{
-			s_template->supported = FALSE;
-		}
-
-		s_template->content_type = g_strdup (_mime_types[i]);
-		s_template->id = (const gchar *)factory->id;
-
-		new_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-New", NULL);
-		add_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Add", NULL);
-		remove_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Remove", NULL);
-		extract_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Extract", NULL);
-		refresh_str_queue = xfce_rc_read_entry(rc, "X-Squeeze-Refresh", NULL);
+        s_template->content_type = g_strdup( _mime_types[i] );
+        s_template->id = (const gchar *)factory->id;
+
+        new_str_queue = xfce_rc_read_entry( rc, "X-Squeeze-New", NULL );
+        add_str_queue = xfce_rc_read_entry( rc, "X-Squeeze-Add", NULL );
+        remove_str_queue = xfce_rc_read_entry( rc, "X-Squeeze-Remove", NULL );
+        extract_str_queue = xfce_rc_read_entry( rc, "X-Squeeze-Extract", NULL );
+        refresh_str_queue = xfce_rc_read_entry( rc, "X-Squeeze-Refresh", NULL );
 
         /* Read the 'new-archive' command-queue from file */	
-		if (NULL != new_str_queue)	
-		{
-			s_template->new_cmd_queue = lsq_command_queue_new(new_str_queue);
-		}
+        if ( NULL != new_str_queue )
+        {
+            s_template->new_cmd_queue = lsq_command_queue_new( new_str_queue );
+            if ( NULL == s_template->new_cmd_queue )
+            {
+                g_warning( "Unable to parse %s in %s", "X-Squeeze-New", filename );
+                g_object_unref( factory );
+                return NULL;
+            }
+        }
 
         /* Read the 'add-to-archive' command-queue from file */	
-		if (NULL != add_str_queue)
-		{
-			s_template->add_cmd_queue = lsq_command_queue_new(add_str_queue);
-		}
+        if ( NULL != add_str_queue )
+        {
+            s_template->add_cmd_queue = lsq_command_queue_new( add_str_queue );
+            if ( NULL == s_template->add_cmd_queue )
+            {
+                g_warning( "Unable to parse %s in %s", "X-Squeeze-Add", filename );
+                g_object_unref( factory );
+                return NULL;
+            }
+        }
 
         /* Read the 'remove-to-archive' command-queue from file */	
-		if (NULL != remove_str_queue)
-		{
-			s_template->remove_cmd_queue = lsq_command_queue_new(remove_str_queue);
-		}
+        if ( NULL != remove_str_queue )
+        {
+            s_template->remove_cmd_queue = lsq_command_queue_new( remove_str_queue );
+            if ( NULL == s_template->remove_cmd_queue )
+            {
+                g_warning( "Unable to parse %s in %s", "X-Squeeze-Remove", filename );
+                g_object_unref( factory );
+                return NULL;
+            }
+        }
 
         /* Read the 'extract-to-archive' command-queue from file */	
-		if (NULL != extract_str_queue)
-		{
-			s_template->extract_cmd_queue = lsq_command_queue_new(extract_str_queue);
-		}
+        if ( NULL != extract_str_queue )
+        {
+            s_template->extract_cmd_queue = lsq_command_queue_new( extract_str_queue );
+            if ( NULL == s_template->extract_cmd_queue )
+            {
+                g_warning( "Unable to parse %s in %s", "X-Squeeze-Extract", filename );
+                g_object_unref( factory );
+                return NULL;
+            }
+        }
 
         /* Read the 'refresh-archive' command-queue from file */	
-		if (NULL != refresh_str_queue)
-		{
-			s_template->refresh_cmd_queue = lsq_command_queue_new(refresh_str_queue);
-		}
+        if ( NULL != refresh_str_queue )
+        {
+            s_template->refresh_cmd_queue = lsq_command_queue_new( refresh_str_queue );
+            if ( NULL == s_template->refresh_cmd_queue )
+            {
+                g_warning( "Unable to parse %s in %s", "X-Squeeze-Refresh", filename );
+                g_object_unref( factory );
+                return NULL;
+            }
+        }
 
         /* Add the appropriate options to the template */
-		s_template->add_options = add_options;
-		s_template->remove_options = remove_options;
-		s_template->extract_options = extract_options;
+        s_template->add_options = add_options;
+        s_template->remove_options = remove_options;
+        s_template->extract_options = extract_options;
 
 
-		s_template->n_properties = g_strv_length(column_names);
-		s_template->property_names = column_names;
-		s_template->parser = parser;
+        s_template->n_properties = g_strv_length(column_names);
+        s_template->property_names = column_names;
+        s_template->parser = parser;
 
 #ifdef DEBUG
-		if (s_template->supported)
-		{
-			g_debug("%s supported\n", _mime_types[i]);
-		}
-		else
-		{
-			g_debug("%s not supported\n", _mime_types[i]);
-		}
+        if ( TRUE == s_template->supported )
+        {
+            g_debug( "%s supported\n", _mime_types[i] );
+        }
+        else
+        {
+            g_debug( "%s not supported\n", _mime_types[i] );
+        }
 #endif
 
-		lsq_support_factory_add_template(factory, s_template);
-	}
-	 
-	return factory;
+        lsq_support_factory_add_template( factory, s_template );
+    }
+
+    return factory;
 }
 
diff --git a/libsqueeze/support-reader.h b/libsqueeze/support-reader.h
index 9255fa7..8990494 100644
--- a/libsqueeze/support-reader.h
+++ b/libsqueeze/support-reader.h
@@ -18,43 +18,9 @@
 
 G_BEGIN_DECLS
 
-#define LSQ_TYPE_SUPPORT_READER lsq_support_reader_get_type()
 
-#define LSQ_SUPPORT_READER(obj)		 ( \
-		G_TYPE_CHECK_INSTANCE_CAST ((obj),	\
-			LSQ_TYPE_SUPPORT_READER,	  \
-			LSQSupportReader))
-
-#define LSQ_IS_SUPPORT_READER(obj)	  ( \
-		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
-			LSQ_TYPE_SUPPORT_READER))
-
-#define LSQ_SUPPORT_READER_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
-			LSQ_TYPE_SUPPORT_READER,	  \
-			LSQSupportReaderClass))
-
-#define LSQ_IS_SUPPORT_READER_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
-			LSQ_TYPE_SUPPORT_READER))
-
-typedef struct _LSQSupportReader LSQSupportReader;
-
-struct _LSQSupportReader
-{
-	GObject		parent;
-};
-
-typedef struct _LSQSupportReaderClass LSQSupportReaderClass;
-
-struct _LSQSupportReaderClass
-{
-	GObjectClass parent;
-}; 
-
-GType			  lsq_support_reader_get_type(void);
-LSQSupportReader  *lsq_support_reader_new();
-LSQSupportFactory *lsq_support_reader_parse_file(const gchar *filename);
+LSQSupportFactory *
+lsq_support_reader_parse_file ( const gchar *filename ) G_GNUC_WARN_UNUSED_RESULT;
 
 
 G_END_DECLS
diff --git a/libsqueeze/support-template.c b/libsqueeze/support-template.c
index e3116cb..480c832 100644
--- a/libsqueeze/support-template.c
+++ b/libsqueeze/support-template.c
@@ -31,44 +31,54 @@
 GType
 lsq_support_template_get_property_type (
         LSQSupportTemplate *templ,
-        guint nr)
+        guint nr
+    )
 {
-    g_return_val_if_fail(templ->parser, G_TYPE_NONE);
-
-	return lsq_parser_get_property_type(templ->parser, nr);
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != templ, G_TYPE_NONE );
+    g_return_val_if_fail( templ->n_properties > nr, G_TYPE_NONE );
+    g_return_val_if_fail( LSQ_IS_PARSER( templ->parser ), G_TYPE_NONE);
+#endif
+    return lsq_parser_get_property_type( templ->parser, nr );
 }
 
 guint
 lsq_support_template_get_property_offset (
         LSQSupportTemplate *templ,
-        guint nr )
+        guint nr
+    )
 {
-    g_return_val_if_fail(templ->parser, 0);
-
-    return lsq_parser_get_property_offset(templ->parser, nr);
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != templ, 0 );
+    g_return_val_if_fail( templ->n_properties > nr, 0 );
+    g_return_val_if_fail( LSQ_IS_PARSER( templ->parser ), 0 );
+#endif
+    return lsq_parser_get_property_offset( templ->parser, nr );
 }
 
 const gchar *
 lsq_support_template_get_property_name (
         LSQSupportTemplate *templ,
-        guint nr )
+        guint nr
+    )
 {
-	g_return_val_if_fail(nr < templ->n_properties, NULL);
+    g_return_val_if_fail( NULL != templ, NULL );
+    g_return_val_if_fail( templ->n_properties > nr, NULL );
 
-	return templ->property_names[nr];
+    return templ->property_names[nr];
 }
 
 guint
-lsq_support_template_get_n_properties (
-        LSQSupportTemplate *templ )
+lsq_support_template_get_n_properties ( LSQSupportTemplate *templ )
 {
     guint n_props;
 
 #ifdef DEBUG
-    g_return_val_if_fail(templ, 0);
+    g_return_val_if_fail( NULL != templ, 0 );
+    g_return_val_if_fail( LSQ_IS_PARSER( templ->parser ), 0 );
 #endif
 
-    n_props = lsq_parser_n_properties ( templ->parser );
+    n_props = lsq_parser_n_properties( templ->parser );
 
     if ( templ->n_properties > n_props )
     {
@@ -78,9 +88,11 @@ lsq_support_template_get_n_properties (
 }
 
 guint
-lsq_support_template_get_properties_size (
-        LSQSupportTemplate *templ )
+lsq_support_template_get_properties_size ( LSQSupportTemplate *templ )
 {
-    g_return_val_if_fail ( templ->parser, 0 );
-    return lsq_parser_get_properties_size ( templ->parser );
+#ifdef DEBUG
+    g_return_val_if_fail( NULL != templ, 0 );
+    g_return_val_if_fail( LSQ_IS_PARSER( templ->parser ), 0 );
+#endif
+    return lsq_parser_get_properties_size( templ->parser );
 }
diff --git a/libsqueeze/support-template.h b/libsqueeze/support-template.h
index d9c18e9..6f01571 100644
--- a/libsqueeze/support-template.h
+++ b/libsqueeze/support-template.h
@@ -65,21 +65,22 @@ struct _LSQSupportTemplate
 GType
 lsq_support_template_get_property_type (
         LSQSupportTemplate *s_template,
-        guint n);
+        guint n
+    ) G_GNUC_PURE;
 guint
 lsq_support_template_get_property_offset (
         LSQSupportTemplate *s_template,
-        guint n);
+        guint n
+    ) G_GNUC_PURE;
 const gchar *
 lsq_support_template_get_property_name (
         LSQSupportTemplate *s_template,
-        guint n );
+        guint n
+    ) G_GNUC_PURE;
 guint
-lsq_support_template_get_n_properties (
-        LSQSupportTemplate *s_template );
+lsq_support_template_get_n_properties ( LSQSupportTemplate *s_template) G_GNUC_PURE;
 guint
-lsq_support_template_get_properties_size (
-        LSQSupportTemplate *s_template );
+lsq_support_template_get_properties_size ( LSQSupportTemplate *s_template ) G_GNUC_PURE;
 
 
 #endif /* __SUPPORT_TEMPLATE_H__ */
diff --git a/src/application.h b/src/application.h
index 5b79074..3d84449 100644
--- a/src/application.h
+++ b/src/application.h
@@ -34,8 +34,8 @@ G_BEGIN_DECLS
 			SQ_TYPE_APPLICATION,	  \
 			SQApplicationClass))
 
-#define SQ_IS_APPLICATION_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_APPLICATION_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			SQ_TYPE_APPLICATION()))	
 
 typedef struct _SQApplication SQApplication;
diff --git a/src/archive_store.c b/src/archive_store.c
index 03f8e74..968c992 100644
--- a/src/archive_store.c
+++ b/src/archive_store.c
@@ -497,7 +497,7 @@ sq_archive_store_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
 
 	g_return_val_if_fail(archive, NULL);
 
-	entry = (LSQArchiveIter*)iter->user_data;
+	entry = (LSQArchiveIter *)iter->user_data;
 	pos = GPOINTER_TO_INT(iter->user_data3);
 
 	if(store->props._show_up_dir && lsq_archive_iter_has_parent(entry))
@@ -930,7 +930,7 @@ sq_archive_store_sort(SQArchiveStore *store)
 	pentry = store->navigation.present->data;
 	psize = lsq_archive_iter_n_children(pentry);
 
-	store->sort_list = g_new(LSQArchiveIter*, psize+1);
+	store->sort_list = g_new(LSQArchiveIter *, psize+1);
 
 	for(i = 0; i < psize; ++i)
 	{
diff --git a/src/archive_store.h b/src/archive_store.h
index 5fc9b11..9770373 100644
--- a/src/archive_store.h
+++ b/src/archive_store.h
@@ -27,13 +27,13 @@
 		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
 			SQ_TYPE_ARCHIVE_STORE))
 
-#define SQ_ARCHIVE_STORE_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
+#define SQ_ARCHIVE_STORE_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
 			SQ_TYPE_ARCHIVE_STORE,	  \
 			SQArchiveStoreClass))
 
-#define SQ_IS_ARCHIVE_STORE_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_ARCHIVE_STORE_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			SQ_TYPE_ARCHIVE_STORE))
 
 typedef struct _SQArchiveStore SQArchiveStore;
diff --git a/src/button_drag_box.c b/src/button_drag_box.c
index 6f3ca93..bba6678 100644
--- a/src/button_drag_box.c
+++ b/src/button_drag_box.c
@@ -29,7 +29,7 @@
 #define SQ_BUTTON_USER_DATA "sq-user-data"
 #define SQ_DRAG_TARGET_ID "_SQ_BUTTON_DRAG_BOX"
 
-static GdkPixbuf*
+static GdkPixbuf *
 sq_create_icon_from_widget(GtkWidget *widget);
 
 static void
@@ -195,7 +195,7 @@ sq_button_drag_box_get_hidden(SQButtonDragBox *box)
 	return list;
 }
 
-static GdkPixbuf*
+static GdkPixbuf *
 sq_create_icon_from_widget(GtkWidget *widget)
 {
 	GdkWindow *drawable = GDK_DRAWABLE(gtk_widget_get_parent_window(widget));
diff --git a/src/button_drag_box.h b/src/button_drag_box.h
index c6dd02d..f5041be 100644
--- a/src/button_drag_box.h
+++ b/src/button_drag_box.h
@@ -36,8 +36,8 @@ G_BEGIN_DECLS
 			SQ_TYPE_BUTTON_DRAG_BOX,	  \
 			SQButtonDragBoxClass))
 
-#define SQ_IS_BUTTON_DRAG_BOX_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_BUTTON_DRAG_BOX_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			SQ_TYPE_BUTTON_DRAG_BOX()))	
 
 typedef struct _SQButtonDragBox SQButtonDragBox;
diff --git a/src/extract_dialog.h b/src/extract_dialog.h
index eb99311..fb079cd 100644
--- a/src/extract_dialog.h
+++ b/src/extract_dialog.h
@@ -27,13 +27,13 @@ G_BEGIN_DECLS
 		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
 			sq_extract_archive_dialog_get_type()))
 
-#define SQ_EXTRACT_ARCHIVE_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
+#define SQ_EXTRACT_ARCHIVE_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
 			sq_extract_archive_dialog_get_type(),	  \
 			SQExtractArchiveDialogClass))
 
-#define SQ_IS_EXTRACT_ARCHIVE_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_EXTRACT_ARCHIVE_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			sq_extract_archive_dialog_get_type()))
 
 typedef struct _SQExtractArchiveDialog SQExtractArchiveDialog;
diff --git a/src/main_window.c b/src/main_window.c
index 72bcc15..f50029c 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -630,7 +630,7 @@ sq_main_window_find_image(gchar *filename, GtkIconSize size)
 	GtkWidget *file_image;
 	gchar *path;
 	GdkPixbuf *file_pixbuf;
-	path = g_strconcat(DATADIR, "/pixmaps/squeeze/", filename, NULL);
+	path = g_build_filename(DATADIR, "pixmaps/squeeze", filename, NULL);
 
 	gtk_icon_size_lookup(size, &width, &height);
 
@@ -805,7 +805,7 @@ cb_sq_main_extract_archive(GtkWidget *widget, gpointer userdata)
 
 	LSQArchive		*lp_archive = NULL;
 
-  const gchar **strv;
+  gchar **strv;
 
 	GSList *filenames = sq_notebook_get_selected_items(SQ_NOTEBOOK(window->notebook));
 
@@ -826,7 +826,7 @@ cb_sq_main_extract_archive(GtkWidget *widget, gpointer userdata)
 		if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, strv, extract_archive_path))
 		{
 			GtkWidget *warning_dialog;
-      g_free(strv);
+      g_strfreev(strv);
 			warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), 
 															   GTK_DIALOG_DESTROY_WITH_PARENT, 
 																												 GTK_MESSAGE_WARNING,
@@ -839,7 +839,7 @@ cb_sq_main_extract_archive(GtkWidget *widget, gpointer userdata)
 			}
 		}
     else
-      g_free(strv);
+      g_strfreev(strv);
 		g_free(extract_archive_path);
 		extract_archive_path = NULL;
 	}
@@ -875,11 +875,11 @@ cb_sq_main_add_files_to_archive(GtkWidget *widget, gpointer userdata)
 		filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
 		if(filenames)
 		{
-      const gchar **strv = lsq_iter_list_to_strv(filenames);
+      gchar **strv = lsq_iter_list_to_strv(filenames);
 			if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, strv, NULL))
 			{
 				GtkWidget *warning_dialog;
-        g_free(strv);
+        g_strfreev(strv);
 				warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), 
 																													 GTK_DIALOG_DESTROY_WITH_PARENT, 
 																													 GTK_MESSAGE_WARNING,
@@ -889,7 +889,7 @@ cb_sq_main_add_files_to_archive(GtkWidget *widget, gpointer userdata)
 				gtk_widget_destroy(warning_dialog);
 			}
       else
-        g_free(strv);
+        g_strfreev(strv);
 		}
 	}
 	gtk_widget_destroy (dialog);
@@ -922,11 +922,11 @@ cb_sq_main_add_folders_to_archive(GtkWidget *widget, gpointer userdata)
 		filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
 		if(filenames)
 		{
-      const gchar **strv = lsq_iter_list_to_strv(filenames);
+      gchar **strv = lsq_iter_list_to_strv(filenames);
 			if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_ADD, strv, NULL))
 			{
 				GtkWidget *warning_dialog;
-        g_free(strv);
+        g_strfreev(strv);
 				warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window),
 									  GTK_DIALOG_DESTROY_WITH_PARENT, 
 									  GTK_MESSAGE_WARNING,
@@ -937,7 +937,7 @@ cb_sq_main_add_folders_to_archive(GtkWidget *widget, gpointer userdata)
 				gtk_widget_destroy(warning_dialog);
 			}
       else
-        g_free(strv);
+        g_strfreev(strv);
 		}
 	}
 	gtk_widget_destroy (dialog);
@@ -950,7 +950,7 @@ cb_sq_main_remove_from_archive(GtkWidget *widget, gpointer userdata)
 	LSQArchive		*lp_archive = NULL;
 	GtkWidget *dialog = NULL;
 	gint result = 0;
-  const gchar **strv;
+  gchar **strv;
 	GSList *filenames = sq_notebook_get_selected_items(SQ_NOTEBOOK(window->notebook));
 
 	if(filenames)
@@ -966,7 +966,7 @@ cb_sq_main_remove_from_archive(GtkWidget *widget, gpointer userdata)
 			if(!lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_REMOVE, strv, NULL))
 			{
 				GtkWidget *warning_dialog;
-        g_free(strv);
+        g_strfreev(strv);
 				warning_dialog = gtk_message_dialog_new(GTK_WINDOW(window), 
 																													 GTK_DIALOG_DESTROY_WITH_PARENT, 
 																													 GTK_MESSAGE_WARNING,
@@ -976,7 +976,7 @@ cb_sq_main_remove_from_archive(GtkWidget *widget, gpointer userdata)
 				gtk_widget_destroy(warning_dialog);
 			}
       else
-        g_free(strv);
+        g_strfreev(strv);
 		}
 		gtk_widget_destroy (dialog);
 
@@ -1251,14 +1251,14 @@ cb_sq_main_window_notebook_file_activated(SQNotebook *notebook, LSQArchiveIter *
 	GtkWidget *dialog = gtk_dialog_new_with_buttons("",window,GTK_DIALOG_DESTROY_WITH_PARENT, _("Open"), GTK_RESPONSE_OK, _("Extract"), GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
 	GtkWidget *extr_dialog = NULL;
 	gint result;
-	const gchar **strv;
+	gchar **strv;
 	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE, TRUE, 20);
 	gtk_widget_show(label);
 	result = gtk_dialog_run(GTK_DIALOG(dialog));
 	gtk_widget_hide(dialog);
 
-	strv = g_new(const gchar*, 2);
-  strv[0] = lsq_archive_iter_get_filename(iter);
+	strv = g_new(gchar *, 2);
+  strv[0] = lsq_archive_iter_get_path(iter);
   strv[1] = NULL;
 
 	switch(result)
@@ -1285,7 +1285,7 @@ cb_sq_main_window_notebook_file_activated(SQNotebook *notebook, LSQArchiveIter *
 				extract_archive_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(extr_dialog));
 				if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(SQ_EXTRACT_ARCHIVE_DIALOG(extr_dialog)->all_files_radio)))
 				{
-					g_free(strv);
+					g_strfreev(strv);
 					strv = NULL;
 				}
 				if(lsq_archive_operate(lp_archive, LSQ_COMMAND_TYPE_EXTRACT, strv, extract_archive_path))
@@ -1308,7 +1308,7 @@ cb_sq_main_window_notebook_file_activated(SQNotebook *notebook, LSQArchiveIter *
 		case GTK_RESPONSE_CANCEL: /* CANCEL */
 			break;
 	}
-	g_free(strv);
+	g_strfreev(strv);
 	gtk_widget_destroy(dialog);
 }
 
diff --git a/src/main_window.h b/src/main_window.h
index eb86228..822f9bc 100644
--- a/src/main_window.h
+++ b/src/main_window.h
@@ -51,13 +51,13 @@ typedef enum
 		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
 			sq_main_window_get_type()))
 
-#define SQ_MAIN_WINDOW_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
+#define SQ_MAIN_WINDOW_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
 			sq_main_window_get_type(),	  \
 			SQMainWindowClass))
 
-#define SQ_IS_MAIN_WINDOW_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_MAIN_WINDOW_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			sq_main_window_get_type()))
 
 typedef struct _SQMainWindow SQMainWindow;
diff --git a/src/message_dialog.c b/src/message_dialog.c
index 04599f4..8e19d8b 100644
--- a/src/message_dialog.c
+++ b/src/message_dialog.c
@@ -177,5 +177,5 @@ sq_message_dialog_new(GtkWindowType type, LSQArchive *archive)
 	gtk_label_set_text(GTK_LABEL(dialog->message_label), filename);
 	g_free(filename);
 
-	return (GtkWidget*)dialog;
+	return (GtkWidget *)dialog;
 }
diff --git a/src/message_dialog.h b/src/message_dialog.h
index 442d4d6..8ccb396 100644
--- a/src/message_dialog.h
+++ b/src/message_dialog.h
@@ -27,13 +27,13 @@ G_BEGIN_DECLS
 		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
 			sq_message_dialog_get_type()))
 
-#define SQ_MESSAGE_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
+#define SQ_MESSAGE_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
 			sq_message_dialog_get_type(),	  \
 			SQMessageDialogClass))
 
-#define SQ_IS_MESSAGE_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_MESSAGE_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			sq_message_dialog_get_type()))
 
 typedef struct _SQMessageDialog SQMessageDialog;
diff --git a/src/navigation_bar.h b/src/navigation_bar.h
index 37cd123..4554fd3 100644
--- a/src/navigation_bar.h
+++ b/src/navigation_bar.h
@@ -34,8 +34,8 @@ G_BEGIN_DECLS
 			SQ_TYPE_NAVIGATION_BAR,	  \
 			SQNavigationBarClass))
 
-#define SQ_IS_NAVIGATION_BAR_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_NAVIGATION_BAR_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			SQ_TYPE_NAVIGATION_BAR()))	
 
 typedef struct _SQNavigationBar SQNavigationBar;
diff --git a/src/new_dialog.h b/src/new_dialog.h
index 21668d5..79073ad 100644
--- a/src/new_dialog.h
+++ b/src/new_dialog.h
@@ -29,13 +29,13 @@ G_BEGIN_DECLS
 		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
 			sq_new_archive_dialog_get_type()))
 
-#define SQ_NEW_ARCHIVE_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
+#define SQ_NEW_ARCHIVE_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
 			sq_new_archive_dialog_get_type(),	  \
 			SQNewArchiveDialogClass))
 
-#define SQ_IS_NEW_ARCHIVE_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_NEW_ARCHIVE_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			sq_new_archive_dialog_get_type()))
 
 typedef struct _SQNewArchiveDialog SQNewArchiveDialog;
diff --git a/src/notebook.h b/src/notebook.h
index 0366ba1..b104c26 100644
--- a/src/notebook.h
+++ b/src/notebook.h
@@ -29,13 +29,13 @@ G_BEGIN_DECLS
 		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
 			sq_notebook_get_type()))
 
-#define SQ_NOTEBOOK_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
+#define SQ_NOTEBOOK_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
 			sq_notebook_get_type(),	  \
 			SQNotebookClass))
 
-#define SQ_IS_NOTEBOOK_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_NOTEBOOK_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			sq_notebook_get_type()))
 
 typedef struct _SQNotebook SQNotebook;
diff --git a/src/path_bar.c b/src/path_bar.c
index cd41b6f..2bb3b4d 100644
--- a/src/path_bar.c
+++ b/src/path_bar.c
@@ -126,8 +126,8 @@ sq_path_bar_class_init(SQPathBarClass *path_bar_class)
 	GtkWidgetClass *widget_class;
 	GtkContainerClass *container_class;
 
-	widget_class = (GtkWidgetClass*)path_bar_class;
-	container_class = (GtkContainerClass*)path_bar_class;
+	widget_class = (GtkWidgetClass *)path_bar_class;
+	container_class = (GtkContainerClass *)path_bar_class;
 
 	widget_class->size_request = sq_path_bar_size_request;
 	widget_class->size_allocate = sq_path_bar_size_allocate;
@@ -367,7 +367,7 @@ sq_path_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
 			}
 		}
 
-		iter = (GSList*)first_display->data;
+		iter = (GSList *)first_display->data;
 
 		/* are there parent maps visible? */
 		while(iter)
@@ -382,7 +382,7 @@ sq_path_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
 		/* which parent map is visible? */
 		while(iter)
 		{
-			gtk_widget_get_child_requisition(GTK_WIDGET(((GSList*)iter->data)->data), &child_requisition);
+			gtk_widget_get_child_requisition(GTK_WIDGET(((GSList *)iter->data)->data), &child_requisition);
 			width += child_requisition.width + spacing;
 			if(width > allocation->width)
 				break;
@@ -443,7 +443,7 @@ sq_path_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
 		width += left_width + spacing;
 	if(right_width)
 		width += spacing + right_width;
-	iter = (GSList*)first_display->data;
+	iter = (GSList *)first_display->data;
 	while(iter)
 	{
 		gtk_widget_get_child_requisition(GTK_WIDGET(iter->data), &child_requisition);
@@ -513,7 +513,7 @@ sq_path_bar_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
 
 	while(iter)
 	{
-		gtk_widget_set_child_visible(GTK_WIDGET(((GSList*)iter->data)->data), FALSE);
+		gtk_widget_set_child_visible(GTK_WIDGET(((GSList *)iter->data)->data), FALSE);
 		iter = iter->next;
 	}
 
diff --git a/src/path_bar.h b/src/path_bar.h
index 3c45e28..eaea3fd 100644
--- a/src/path_bar.h
+++ b/src/path_bar.h
@@ -34,8 +34,8 @@ G_BEGIN_DECLS
 			SQ_TYPE_PATH_BAR,	  \
 			SQPathBarClass))
 
-#define SQ_IS_PATH_BAR_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_PATH_BAR_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			SQ_TYPE_PATH_BAR()))	
 
 typedef struct _SQPathBar SQPathBar;
diff --git a/src/preferences_dialog.h b/src/preferences_dialog.h
index a5bbedb..9313f4b 100644
--- a/src/preferences_dialog.h
+++ b/src/preferences_dialog.h
@@ -27,13 +27,13 @@ G_BEGIN_DECLS
 		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
 			sq_preferences_dialog_get_type()))
 
-#define SQ_PREFERENCES_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
+#define SQ_PREFERENCES_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
 			sq_preferences_dialog_get_type(),	  \
 			SQPreferencesDialogClass))
 
-#define SQ_IS_PREFERENCES_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_PREFERENCES_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			sq_preferences_dialog_get_type()))
 
 typedef struct
diff --git a/src/properties_dialog.h b/src/properties_dialog.h
index 9731426..ba19a7c 100644
--- a/src/properties_dialog.h
+++ b/src/properties_dialog.h
@@ -32,13 +32,13 @@ G_BEGIN_DECLS
 		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
 			sq_properties_dialog_get_type()))
 
-#define SQ_PROPERTIES_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
+#define SQ_PROPERTIES_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
 			sq_properties_dialog_get_type(),	  \
 			SQPropertiesDialogClass))
 
-#define SQ_IS_PROPERTIES_DIALOG_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_PROPERTIES_DIALOG_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			sq_properties_dialog_get_type()))
 
 typedef struct _SQPropertiesDialog SQPropertiesDialog;
diff --git a/src/settings.h b/src/settings.h
index 6fa4eca..fffa9f3 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -29,13 +29,13 @@ G_BEGIN_DECLS
 		G_TYPE_CHECK_INSTANCE_TYPE ((obj),	\
 			sq_settings_get_type()))
 
-#define SQ_SETTINGS_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_CAST ((class),	 \
+#define SQ_SETTINGS_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_CAST ((klass),	 \
 			sq_settings_get_type(),	  \
 			SQSettingsClass))
 
-#define SQ_IS_SETTINGS_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_SETTINGS_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			sq_settings_get_type()))
 
 typedef struct _SQSettings SQSettings;
diff --git a/src/throbber.c b/src/throbber.c
index c7fb347..cd7ae15 100644
--- a/src/throbber.c
+++ b/src/throbber.c
@@ -337,7 +337,7 @@ sq_throbber_timer_destroy (gpointer user_data)
  *
  * Return value: the newly allocated #SQThrobber.
  **/
-GtkWidget*
+GtkWidget *
 sq_throbber_new (void)
 {
 	return g_object_new (SQ_TYPE_THROBBER, NULL);
diff --git a/src/tool_bar.c b/src/tool_bar.c
index e45caa5..68ad636 100644
--- a/src/tool_bar.c
+++ b/src/tool_bar.c
@@ -49,7 +49,7 @@ static void
 sq_tool_bar_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
 
 static void
-cb_sq_tool_bar_pwd_changed(SQArchiveStore *store, LSQArchiveIter*, SQNavigationBar *bar);
+cb_sq_tool_bar_pwd_changed(SQArchiveStore *store, LSQArchiveIter *, SQNavigationBar *bar);
 static void
 cb_sq_tool_bar_new_archive(SQArchiveStore *store, SQNavigationBar *bar);
 static void
@@ -102,8 +102,8 @@ sq_tool_bar_class_init(SQToolBarClass *tool_bar_class)
 	GtkWidgetClass *widget_class;
 	GtkContainerClass *container_class;
 
-	widget_class = (GtkWidgetClass*)tool_bar_class;
-	container_class = (GtkContainerClass*)tool_bar_class;
+	widget_class = (GtkWidgetClass *)tool_bar_class;
+	container_class = (GtkContainerClass *)tool_bar_class;
 
 	widget_class->size_request = sq_tool_bar_size_request;
 	widget_class->size_allocate = sq_tool_bar_size_allocate;
@@ -281,7 +281,7 @@ sq_tool_bar_add(GtkContainer *container, GtkWidget *child)
 
 	g_return_if_fail(GTK_IS_WIDGET(child));
 
-	if(((GtkWidget*)tool_bar->bar) != child)
+	if(((GtkWidget *)tool_bar->bar) != child)
 	{
 		g_warning("DON'T set another child as toolbar");
 		return;
@@ -297,7 +297,7 @@ sq_tool_bar_remove(GtkContainer *container, GtkWidget *child)
 	gboolean widget_was_visible;
 
 	g_return_if_fail(GTK_IS_WIDGET(child));
-	g_return_if_fail(((GtkWidget*)tool_bar->bar) == child);
+	g_return_if_fail(((GtkWidget *)tool_bar->bar) == child);
 
 	widget_was_visible = GTK_WIDGET_VISIBLE(child);
 
diff --git a/src/tool_bar.h b/src/tool_bar.h
index 8f0dbfa..02466a4 100644
--- a/src/tool_bar.h
+++ b/src/tool_bar.h
@@ -34,8 +34,8 @@ G_BEGIN_DECLS
 			SQ_TYPE_TOOL_BAR,	  \
 			SQToolBarClass))
 
-#define SQ_IS_TOOL_BAR_CLASS(class) ( \
-		G_TYPE_CHECK_CLASS_TYPE ((class),		\
+#define SQ_IS_TOOL_BAR_CLASS(klass) ( \
+		G_TYPE_CHECK_CLASS_TYPE ((klass),		\
 			SQ_TYPE_TOOL_BAR()))	
 
 typedef struct _SQToolBar SQToolBar;
diff --git a/src/widget_factory.c b/src/widget_factory.c
index 33a3c69..4f8e5c8 100644
--- a/src/widget_factory.c
+++ b/src/widget_factory.c
@@ -37,28 +37,28 @@ sq_widget_factory_class_init(SQWidgetFactoryClass *factory_class);
 static void
 sq_widget_factory_init(SQWidgetFactory *factory);
 
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_boolean_widget(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_numeric_widget(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_enum_widget_group(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_enum_widget_list(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_flags_widget(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_string_widget(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
 
-static GSList*
+static GSList *
 sq_widget_factory_create_boolean_menu(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
-static GSList*
+static GSList *
 sq_widget_factory_create_enum_menu_group(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
-static GSList*
+static GSList *
 sq_widget_factory_create_enum_menu_list(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
-static GSList*
+static GSList *
 sq_widget_factory_create_flags_menu_group(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
-static GSList*
+static GSList *
 sq_widget_factory_create_flags_menu_list(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value);
 
 static void
@@ -116,7 +116,7 @@ sq_widget_factory_init(SQWidgetFactory *factory)
 	/* factory->custom_callback->notify_func = (LSQCustomActionNotifyFunc)sq_widget_factory_notify; */
 }
 
-SQWidgetFactory*
+SQWidgetFactory *
 sq_widget_factory_new(void)
 {
 	SQWidgetFactory *factory;
@@ -126,7 +126,7 @@ sq_widget_factory_new(void)
 	return factory;
 }
 
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_boolean_widget(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GtkWidget *check = gtk_check_button_new_with_label(g_param_spec_get_nick(pspec));
@@ -162,7 +162,7 @@ sq_widget_factory_create_boolean_widget(SQWidgetFactory *factory, GObject *obj,
 	return check;
 }
 
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_numeric_widget(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GtkWidget *box = gtk_hbox_new(FALSE, 3);
@@ -279,7 +279,7 @@ sq_widget_factory_create_numeric_widget(SQWidgetFactory *factory, GObject *obj,
 	return box;
 }
 
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_enum_widget_group(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GtkWidget *frame = gtk_frame_new(g_param_spec_get_nick(pspec));
@@ -328,7 +328,7 @@ sq_widget_factory_create_enum_widget_group(SQWidgetFactory *factory, GObject *ob
 	return frame;
 }
 
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_enum_widget_list(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GtkWidget *box = gtk_hbox_new(FALSE, 3);
@@ -379,7 +379,7 @@ sq_widget_factory_create_enum_widget_list(SQWidgetFactory *factory, GObject *obj
 	return box;
 }
 
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_flags_widget(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GtkWidget *frame = gtk_frame_new(g_param_spec_get_nick(pspec));
@@ -427,7 +427,7 @@ sq_widget_factory_create_flags_widget(SQWidgetFactory *factory, GObject *obj, GP
 	return frame;
 }
 
-static GtkWidget*
+static GtkWidget *
 sq_widget_factory_create_string_widget(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GtkWidget *box = gtk_hbox_new(FALSE, 3);
@@ -468,7 +468,7 @@ sq_widget_factory_create_string_widget(SQWidgetFactory *factory, GObject *obj, G
 	return box;
 }
 
-GtkWidget*
+GtkWidget *
 sq_widget_factory_create_property_widget(SQWidgetFactory *factory, GObject *obj, const gchar *prop)
 {
 	GtkWidget *widget = NULL;
@@ -525,7 +525,7 @@ sq_widget_factory_create_property_widget(SQWidgetFactory *factory, GObject *obj,
 	return widget;
 }
 
-static GSList*
+static GSList *
 sq_widget_factory_create_boolean_menu(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GSList *menu = NULL;
@@ -550,7 +550,7 @@ sq_widget_factory_create_boolean_menu(SQWidgetFactory *factory, GObject *obj, GP
 	return menu;
 }
 
-static GSList*
+static GSList *
 sq_widget_factory_create_enum_menu_group(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GSList *menu = NULL;
@@ -584,7 +584,7 @@ sq_widget_factory_create_enum_menu_group(SQWidgetFactory *factory, GObject *obj,
 	return menu;
 }
 
-static GSList*
+static GSList *
 sq_widget_factory_create_enum_menu_list(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GSList *menu = NULL;
@@ -628,7 +628,7 @@ sq_widget_factory_create_enum_menu_list(SQWidgetFactory *factory, GObject *obj,
 	return menu;
 }
 
-static GSList*
+static GSList *
 sq_widget_factory_create_flags_menu_group(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GSList *menu = NULL;
@@ -661,7 +661,7 @@ sq_widget_factory_create_flags_menu_group(SQWidgetFactory *factory, GObject *obj
 	return menu;
 }
 
-static GSList*
+static GSList *
 sq_widget_factory_create_flags_menu_list(SQWidgetFactory *factory, GObject *obj, GParamSpec *pspec, const GValue *value)
 {
 	GSList *menu = NULL;
@@ -701,7 +701,7 @@ sq_widget_factory_create_flags_menu_list(SQWidgetFactory *factory, GObject *obj,
 	return menu;
 }
 
-GSList*
+GSList *
 sq_widget_factory_create_property_menu(SQWidgetFactory *factory, GObject *obj, const gchar *prop)
 {
 	GSList *menu = NULL;


More information about the Xfce4-commits mailing list