diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 9f19ac3..016488b 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -30,6 +30,8 @@
 #include <string.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#include <stdarg.h>
+#include "sprintf.h"
 #include "debug.h"
 #include "system.h"
 #include "logf.h"
@@ -73,7 +75,7 @@ static unsigned int  cache_build_ticks = 0;
 static unsigned long appflags = 0;

 static struct event_queue dircache_queue;
-static long dircache_stack[(DEFAULT_STACK_SIZE + 0x200)/sizeof(long)];
+static long dircache_stack[(DEFAULT_STACK_SIZE + 0x400)/sizeof(long)];
 static const char dircache_thread_name[] = "dircache";

 static struct fdbind_queue fdbind_cache[MAX_PENDING_BINDINGS];
@@ -179,8 +181,34 @@ static struct
 #endif
     struct fat_dir *dir;
     struct fat_direntry *direntry;
+    int depth;
+    int fd;
 }sab;

+static int sab_logf_push(void *userp, unsigned char c)
+{
+    write(sab.fd, &c, sizeof(c));
+
+    return true;
+}
+
+static void sab_logf(const char *fmt, ...)
+{
+    va_list ap;
+    if(sab.fd < 0)
+        return;
+
+    va_start(ap, fmt);
+    
+    vuprintf(sab_logf_push, NULL, fmt, ap);
+    va_end(ap);
+    
+    /* add trailing zero */
+    sab_logf_push(NULL, '\n');
+
+    fsync(sab.fd);
+}
+
 static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce)
 {
     /* normally, opendir expects a full fat_dir as parent but in our case,
@@ -209,6 +237,9 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce
         if(!strcmp(".", sab.direntry->name) ||
                 !strcmp("..", sab.direntry->name))
             continue;
+
+        sab_logf("%d: %s", sab.depth, sab.direntry->name);
+        _logf("%d: %s", sab.depth, sab.direntry->name);

         ce->attribute = sab.direntry->attr;
         ce->name_len = strlen(sab.direntry->name) + 1;
@@ -229,7 +260,6 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce
         if(ce == NULL)
             return -5;

-        /* When simulator is used, it's only safe to yield here. */
         if(thread_enabled)
         {
             /* Stop if we got an external signal. */
@@ -261,8 +291,10 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce

     while(rc >= 0 && ce)
     {
+        sab.depth++;
         if(ce->name_len != 0 && ce->down != NULL && strcmp(ce->d_name, ".") && strcmp(ce->d_name, ".."))
             rc = sab_process_dir(ce->startcluster, ce->down);
+        sab.depth--;

         ce = ce->next;
     }
@@ -272,6 +304,7 @@ static int sab_process_dir(unsigned long startcluster, struct dircache_entry *ce

 /* used during the generation */
 static struct fat_dir sab_fat_dir;
+static struct fat_direntry sab_fat_direntry;

 static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce)
 {
@@ -291,12 +324,11 @@ static int dircache_scan_and_build(IF_MV2(int volume,) struct dircache_entry *ce
     }
 #endif

-    struct fat_direntry direntry; /* ditto */
 #ifdef HAVE_MULTIVOLUME
     sab.volume = volume;
 #endif
     sab.dir = &sab_fat_dir;
-    sab.direntry = &direntry;
+    sab.direntry = &sab_fat_direntry;

     return sab_process_dir(0, ce);
 }
@@ -510,7 +542,7 @@ int dircache_load(void)
     dircache_root = buffer_alloc(0);
     if ((long)maindata.root_entry != (long)dircache_root)
     {
-        logf("Position missmatch");
+        logf("Position mismatch");
         close(fd);
         remove(DIRCACHE_FILE);
         return -4;
@@ -602,6 +634,8 @@ static int dircache_do_rebuild(void)

     dircache_size = sizeof(struct dircache_entry);

+    sab.fd = open("/sab_logf.txt", O_RDWR | O_TRUNC | O_CREAT);
+
 #ifdef HAVE_MULTIVOLUME
     append_position = dircache_root;

@@ -629,6 +663,7 @@ static int dircache_do_rebuild(void)
     }
 #endif

+    close(sab.fd);
     logf("Done, %ld KiB used", dircache_size / 1024);

     dircache_initialized = true;