Index: trunk/psModules/src/config/pmConfigRecipes.c
===================================================================
--- trunk/psModules/src/config/pmConfigRecipes.c	(revision 10470)
+++ trunk/psModules/src/config/pmConfigRecipes.c	(revision 10481)
@@ -64,7 +64,7 @@
     if (config->site && (source & PM_RECIPE_SOURCE_SITE)) {
         if (!loadRecipeFiles(config, config->site, PM_RECIPE_SOURCE_SITE, "site configuration")) {
-            psLogMsg ("psModules.pmConfig", PS_LOG_WARN, "Failed to read recipes from site config");
-        } else {
-            psTrace ("psModules.pmConfig", 3, "read recipes from site config");
+            psLogMsg ("psModules.config", PS_LOG_WARN, "Failed to read recipes from site config");
+        } else {
+            psTrace ("psModules.config", 3, "read recipes from site config");
         }
     }
@@ -76,7 +76,7 @@
     if (config->camera && (source & PM_RECIPE_SOURCE_CAMERA) && !(config->recipesRead & PM_RECIPE_SOURCE_CAMERA)) {
         if (!loadRecipeFiles(config, config->camera, PM_RECIPE_SOURCE_CAMERA, "camera configuration")) {
-            psLogMsg ("psModules.pmConfig", PS_LOG_DETAIL, "no recipe supplied by camera config");
-        } else {
-            psTrace ("psModules.pmConfig", 3, "read recipes from camera config");
+            psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied by camera config");
+        } else {
+            psTrace ("psModules.config", 3, "read recipes from camera config");
         }
     }
@@ -85,17 +85,17 @@
     if (config->arguments && (source & PM_RECIPE_SOURCE_CL)) {
         if (!loadRecipeFromArguments(config)) {
-            psLogMsg ("psModules.pmConfig", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
-        } else {
-            psTrace ("psModules.pmConfig", 3, "read recipes from command-line arguments");
+            psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
+        } else {
+            psTrace ("psModules.config", 3, "read recipes from command-line arguments");
         }
         if (!loadRecipeSymbols(config)) {
-            psLogMsg ("psModules.pmConfig", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
-        } else {
-            psTrace ("psModules.pmConfig", 3, "read recipes from command-line arguments");
+            psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
+        } else {
+            psTrace ("psModules.config", 3, "read recipes from command-line arguments");
         }
         if (!loadRecipeOptions(config)) {
-            psLogMsg ("psModules.pmConfig", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
-        } else {
-            psTrace ("psModules.pmConfig", 3, "read recipes from command-line arguments");
+            psLogMsg ("psModules.config", PS_LOG_DETAIL, "no recipe supplied on command-line arguments");
+        } else {
+            psTrace ("psModules.config", 3, "read recipes from command-line arguments");
         }
     }
@@ -117,8 +117,15 @@
     // save the recipes onto config->arguments:RECIPES
     // increment so we can free below (is a NOP is options is NULL)
-    psMetadata *options = psMemIncrRefCounter (psMetadataLookupMetadata(NULL, config->arguments, "OPTIONS"));
-    if (!options) {
-        options = psMetadataAlloc ();
-        psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA, "", options);
+    psMetadata *options;                // OPTIONS on the arguments
+    psMetadataItem *optionsItem = psMetadataLookup(config->arguments, "OPTIONS");
+    if (optionsItem) {
+        if (optionsItem->type != PS_DATA_METADATA) {
+            psAbort(__func__, "OPTIONS is not of type METADATA.");
+        }
+        options = psMemIncrRefCounter(optionsItem->data.V);
+    } else {
+        options = psMetadataAlloc();
+        psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA,
+                         "Command-line options specified with -D", options);
     }
 
@@ -200,4 +207,16 @@
 bool pmConfigLoadRecipeArguments (pmConfig *config)
 {
+    psMetadata *recipes;                // Recipes in the arguments list
+    psMetadataItem *recipesItem = psMetadataLookup(config->arguments, "RECIPES");
+    if (recipesItem) {
+        if (recipesItem->type != PS_DATA_METADATA) {
+            psAbort(__func__, "RECIPES is not of type METADATA.");
+        }
+        recipes = psMemIncrRefCounter(recipesItem->data.V);
+    } else {
+        recipes = psMetadataAlloc();
+        psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES",  PS_DATA_METADATA, "", recipes);
+    }
+
 
     // Go through the command-line arguments
@@ -218,9 +237,4 @@
             // The source is a file: load onto config->arguments
             // save the recipes onto config->arguments:RECIPES
-            psMetadata *recipes = psMemIncrRefCounter (psMetadataLookupMetadata(NULL, config->arguments, "RECIPES"));
-            if (!recipes) {
-                recipes = psMetadataAlloc ();
-                psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "RECIPES",  PS_DATA_METADATA, "", recipes);
-            }
 
             psMetadata *recipe = NULL;      // Recipe from file
@@ -228,5 +242,6 @@
                 psString comment = psStringCopy("Recipe added at command line from ");
                 psStringAppend(&comment, "%s", recipeSource);
-                psMetadataAdd(recipes, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE, comment, recipe);
+                psMetadataAdd(recipes, PS_LIST_TAIL, recipeName, PS_DATA_METADATA | PS_META_REPLACE,
+                              comment, recipe);
                 psFree(comment);
                 psFree(recipe);                 // Drop reference
@@ -234,15 +249,16 @@
                 psAbort ("pmConfig.c", "error reading config file %s\n", recipeSource);
             }
-            psFree (recipes);
         } else {
             // Assume it's a symbolic reference to something that's not yet read in.
             // it will be loaded later by pmConfigReadRecipes with option CL
-            psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, "", recipeSource);
-        }
-        psTrace ("psModules.pmConfig", 3, "read recipe %s from %s", recipeName, recipeSource);
+            psMetadataAddStr(config->recipeSymbols, PS_LIST_TAIL, recipeName, PS_META_REPLACE, "",
+                             recipeSource);
+        }
+        psTrace ("psModules.config", 3, "read recipe %s from %s", recipeName, recipeSource);
         psFree(recipeName);
         psFree(recipeSource);
     } // Iterating through the command-line arguments
 
+    psFree(recipes);                    // Drop reference
     return true;
 }
@@ -262,5 +278,5 @@
     }
     if (!source) {
-        psTrace("psModules.pmConfig", 4, "The %s has not been read --- cannot read recipes from this "
+        psTrace("psModules.config", 4, "The %s has not been read --- cannot read recipes from this "
                 "location.\n", sourceName);
         config->recipesRead &= ~sourceType;
@@ -270,5 +286,5 @@
     psMetadata *recipes = psMetadataLookupMetadata(NULL, source, "RECIPES"); // The list of recipes
     if (!recipes) {
-        psLogMsg("psModules.pmConfig", PS_LOG_WARN, "RECIPES not found in the %s\n", sourceName);
+        psLogMsg("psModules.config", PS_LOG_WARN, "RECIPES not found in the %s\n", sourceName);
         config->recipesRead &= ~sourceType;
         return false;
@@ -289,6 +305,7 @@
         psString comment = NULL;
         psStringAppend(&comment, "Recipe added at %s from %s", sourceName, (char*)fileItem->data.V);
-        psTrace ("psModules.pmConfig", 3, comment);
-        psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, fileItem->name, PS_META_REPLACE, comment, sourceType);
+        psTrace ("psModules.config", 3, comment);
+        psMetadataAddS32(config->recipesSource, PS_LIST_TAIL, fileItem->name, PS_META_REPLACE,
+                         comment, sourceType);
         psFree(comment);
         #endif
@@ -304,7 +321,15 @@
 
         // if this named recipe exists, supplement it
-        psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes,
-                              fileItem->name));
-        current = psMetadataCopy (current, recipe);
+        psMetadata *current = NULL;     // Current, extant recipe of the same name, to be supplemented
+        psMetadataItem *currentItem = psMetadataLookup(config->recipes, fileItem->name);
+        if (currentItem) {
+            if (currentItem->type != PS_DATA_METADATA) {
+                psAbort(__func__, "Item from recipes is not of type METADATA.");
+            }
+            current = psMemIncrRefCounter(currentItem->data.V);
+            psTrace("psModules.config", 3, "Supplementing %s from %s within %s.\n", currentItem->name,
+                    fileItem->name, sourceName);
+        }
+        current = psMetadataCopy(current, recipe);
         psFree(recipe);  // Drop reference
         psMetadataAdd(config->recipes, PS_LIST_TAIL, fileItem->name, PS_DATA_METADATA | PS_META_REPLACE,
@@ -325,5 +350,5 @@
     assert(config);
     if (!config->arguments) {
-        psTrace("psModules.pmConfig", 4, "no config->arguments metadata, nothing to read here");
+        psTrace("psModules.config", 4, "no config->arguments metadata, nothing to read here");
         return false;
     }
@@ -331,5 +356,5 @@
     psMetadata *recipes = psMetadataLookupMetadata(NULL, config->arguments, "RECIPES"); // The list of recipes
     if (!recipes) {
-        psTrace("psModules.pmConfig", 4, "no RECIPES in config->arguments, nothing to read here");
+        psTrace("psModules.config", 4, "no RECIPES in config->arguments, nothing to read here");
         return false;
     }
@@ -415,5 +440,5 @@
     assert(config);
     if (!config->arguments) {
-        psTrace("psModules.pmConfig", 4, "no config->arguments metadata, nothing to read here");
+        psTrace("psModules.config", 4, "no config->arguments metadata, nothing to read here");
         return false;
     }
@@ -421,5 +446,5 @@
     psMetadata *recipes = psMetadataLookupMetadata(NULL, config->arguments, "OPTIONS"); // The list of recipes
     if (!recipes) {
-        psTrace("psModules.pmConfig", 4, "no OPTIONS in config->arguments, nothing to read here");
+        psTrace("psModules.config", 4, "no OPTIONS in config->arguments, nothing to read here");
         return false;
     }
