diff --git a/src/core/main.c b/src/core/main.c
index c83ebc691..92a2ad058 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -245,7 +245,7 @@ init_environment()
 
   g_setenv ("PATH", path, TRUE);
   g_info ("PATH set to %s\n", path);
-  gchar *lilypond_data_path = g_build_filename (prefix, "share", "lilypond", "current", NULL);
+  gchar *lilypond_data_path = g_build_filename (prefix, "lilypond", "share", "lilypond", "2.24.4", NULL);
   g_setenv ("LILYPOND_DATA_PATH", lilypond_data_path, FALSE);
   g_info ("LILYPOND_DATA_PATH will be %s if not already set", lilypond_data_path);
 
diff --git a/src/core/palettestorage.c b/src/core/palettestorage.c
index c5a08e63d..867fab448 100644
--- a/src/core/palettestorage.c
+++ b/src/core/palettestorage.c
@@ -78,8 +78,16 @@ writePalettes (void)
   xmlDocPtr doc;
   xmlNodePtr parent, child;
   gchar *localpal = NULL;
+  gchar *actions_dir = NULL;
 
-  localpal = g_build_filename (get_user_data_dir (TRUE), "actions", "palettes.xml", NULL);
+  // Build the actions directory path
+  actions_dir = g_build_filename (get_user_data_dir (TRUE), "actions", NULL);
+  
+  // Create the directory if it doesn't exist
+  g_mkdir_with_parents (actions_dir, 0755);
+
+  // Now build the full file path
+  localpal = g_build_filename (actions_dir, "palettes.xml", NULL);
 
   doc = xmlNewDoc ((xmlChar *) "1.0");
   doc->xmlRootNode = parent = xmlNewDocNode (doc, NULL, (xmlChar *) "Denemo", NULL);
@@ -96,6 +104,8 @@ writePalettes (void)
     } else
     ret = 0;
     xmlFreeDoc (doc);
+    g_free (actions_dir);  // Free the allocated memory
+    g_free (localpal);     // Free this too (it was missing!)
     return ret;
 }
 
