diff --git a/service/dconf-writer.c b/service/dconf-writer.c
index 0170046..6b4c74a 100644
--- a/service/dconf-writer.c
+++ b/service/dconf-writer.c
@@ -176,7 +176,7 @@ dconf_writer_real_end (DConfWriter *writer)
       g_slice_free (TaggedChange, change);
     }
 
-  g_clear_pointer (&writer->uncommited_values, g_hash_table_unref);
+  g_clear_pointer (&writer->uncommited_values, dconf_changeset_unref);
 }
 
 gboolean
@@ -307,10 +307,16 @@ dconf_writer_set_property (GObject *object, guint prop_id,
   g_assert (!writer->name);
   writer->name = g_value_dup_string (value);
 
+  gchar* directory;
   if (writer->native)
-    writer->filename = g_build_filename (g_get_user_config_dir (), "dconf", writer->name, NULL);
+    directory = g_build_filename (g_get_user_config_dir(), "dconf", NULL);
   else
-    writer->filename = g_build_filename (g_get_user_runtime_dir (), "dconf", writer->name, NULL);
+    directory = g_build_filename (g_get_user_runtime_dir(), "dconf", NULL);
+  g_mkdir_with_parents (directory, 0700);
+
+  writer->filename = g_build_filename (directory, writer->name, NULL);
+
+  g_free(directory);
 }
 
 static void
