Index: trunk/psModules/src/config/pmConfigRecipes.c
===================================================================
--- trunk/psModules/src/config/pmConfigRecipes.c	(revision 21387)
+++ trunk/psModules/src/config/pmConfigRecipes.c	(revision 23286)
@@ -11,5 +11,5 @@
 #include "pmConfigRecipes.h"
 
-static bool loadRecipeSystem(bool *status, pmConfig *config, psMetadata *source);
+static bool loadRecipeSystem(bool *status, pmConfig *config);
 static bool loadRecipeCamera(bool *status, pmConfig *config, psMetadata *source);
 static bool loadRecipeSymbols(bool *status, pmConfig *config, pmRecipeSource source);
@@ -56,14 +56,10 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    if (!config->recipes) {
-        config->recipes = psMetadataAlloc();
-    }
-
     // Read the recipe file names from the system configuration and camera configuration
     // It is an error for config->system:recipes not to exist.  all programs install their
     // master recipe files in the system:recipe location when they are built.
     psAssert(config->system, "base config data defined");
-    if (source & PM_RECIPE_SOURCE_SYSTEM) {
-        if (!loadRecipeSystem(&status, config, config->system)) {
+    if (!config->recipes || (source & PM_RECIPE_SOURCE_SYSTEM)) {
+        if (!loadRecipeSystem(&status, config)) {
             psError(PS_ERR_IO, false, "Failed to read recipes from system config");
             return false;
@@ -321,6 +317,5 @@
 // Load the recipe files for SYSTEM : REQUIRED
 static bool loadRecipeSystem(bool *status,
-                           pmConfig *config, // The configuration into which to read the recipes
-                           psMetadata *source // The source configuration, from which to read the filenames
+                           pmConfig *config // The configuration into which to read the recipes
     )
 {
@@ -329,5 +324,5 @@
     *status = false;
 
-    if (!source) {
+    if (!config->system) {
         psError(PS_ERR_IO, true,
                 "The system configuration has not been read --- cannot read recipes from this location.\n");
@@ -336,14 +331,14 @@
     }
 
-    psMetadata *recipes = psMetadataLookupMetadata(NULL, source, "RECIPES"); // The list of recipes
-    if (!recipes) {
-        psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n");
-        return false;
-    }
-
-    // Copy contents of the filenames to config->recipes from the "RECIPES" metadata in the source.
-    // We could use psMetadataCopy for this, but it's better to check that everything's of the correct type.
-    // If it's not of the correct type, we can tell the user which file it's in, so they can find it easier.
-    psMetadataIterator *recipesIter = psMetadataIteratorAlloc(recipes, PS_LIST_HEAD, NULL); // Iterator
+    if (!config->recipes) {
+        config->recipes = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->system, "RECIPES")); // The list of recipes
+        if (!config->recipes) {
+            psError(PS_ERR_IO, false, "RECIPES not found in the system configuration\n");
+            return false;
+        }
+    }
+
+    // Read in the component recipes
+    psMetadataIterator *recipesIter = psMetadataIteratorAlloc(config->recipes, PS_LIST_HEAD, NULL); // Iterator
     psMetadataItem *item = NULL;        // MD item containing the filename, from recipe iteration
     while ((item = psMetadataGetAndIncrement(recipesIter))) {
@@ -353,9 +348,5 @@
             psFree(recipesIter);
             return false;
-        }
-
-        // add the contents of this recipe file to config->recipes
-        psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE,
-                      item->comment, item->data.md);
+	}
     }
     psFree(recipesIter);
