Index: /trunk/psModules/src/config/pmConfigRecipes.c
===================================================================
--- /trunk/psModules/src/config/pmConfigRecipes.c	(revision 10502)
+++ /trunk/psModules/src/config/pmConfigRecipes.c	(revision 10503)
@@ -27,22 +27,27 @@
     // if the recipe is already defined in config->arguments, supplement
     // save the recipe options onto config->arguments:RECIPES
-    psMetadata *options = psMetadataLookupMetadata(NULL, config->arguments, "OPTIONS");
-    if (!options) {
+    psMetadata *options;
+    psMetadataItem *optionsItem = psMetadataLookup(config->arguments, "OPTIONS");
+    if (optionsItem) {
+        assert(optionsItem->type == PS_DATA_METADATA);
+        options = psMemIncrRefCounter(optionsItem->data.V);
+    } else {
         options = psMetadataAlloc ();
         psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "OPTIONS",  PS_DATA_METADATA, "", options);
+    }
+
+    // look for the recipe defined in recipes
+    psMetadata *recipe;
+    psMetadataItem *recipeItem = psMetadataLookup(options, recipeName);
+    psFree(options);                   // Drop reference
+    if (recipeItem) {
+        assert(recipeItem->type == PS_DATA_METADATA);
+        recipe = psMemIncrRefCounter(recipeItem->data.V);
     } else {
-        psMemIncrRefCounter (options); // so we can free options below if not allocated here
-    }
-
-    // look for the recipe defined in recipes
-    psMetadata *recipe = psMetadataLookupMetadata(NULL, options, recipeName);
-    if (!recipe) {
-        recipe = psMetadataAlloc ();
-        psMetadataAddPtr (options, PS_LIST_TAIL, recipeName,  PS_DATA_METADATA, "", recipe);
-    } else {
-        psMemIncrRefCounter (recipe); // so we can free options below if not allocated here
-    }
-    psFree (options);
-    return (recipe);
+        recipe = psMetadataAlloc();
+        psMetadataAddPtr(options, PS_LIST_TAIL, recipeName,  PS_DATA_METADATA, "", recipe);
+    }
+
+    return recipe;
 }
 
@@ -163,8 +168,12 @@
 
         // if this recipe is already defined in options, supplement
-        psMetadata *recipe = psMemIncrRefCounter (psMetadataLookupMetadata(NULL, options, recipeName));
-        if (!recipe) {
-            recipe = psMetadataAlloc ();
-            psMetadataAddPtr (options, PS_LIST_TAIL, recipeName,  PS_DATA_METADATA, "", recipe);
+        psMetadata *recipe;
+        psMetadataItem *recipeItem = psMetadataLookup(options, recipeName);
+        if (recipeItem) {
+            assert(recipeItem->type == PS_DATA_METADATA);
+            recipe = psMemIncrRefCounter(recipeItem->data.V);
+        } else {
+            recipe = psMetadataAlloc();
+            psMetadataAddPtr(options, PS_LIST_TAIL, recipeName,  PS_DATA_METADATA, "", recipe);
         }
 
@@ -373,6 +382,10 @@
 
         // if this named recipe exists, supplement it
-        psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes,
-                              item->name));
+        psMetadata *current = NULL;
+        psMetadataItem *currentItem = psMetadataLookup(config->recipes, item->name);
+        if (currentItem) {
+            assert(currentItem->type == PS_DATA_METADATA);
+            current = psMemIncrRefCounter(currentItem->data.V);
+        }
         current = psMetadataCopy (current, recipe);
         psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE,
@@ -402,10 +415,18 @@
 
         // search for linkName in config->recipes
-        psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, symbolRef); // The source
-        if (recipe) {
+        psMetadataItem *recipeItem = psMetadataLookup(config->recipes, symbolRef);
+        if (recipeItem) {
             // if this named recipe exists, supplement it
+            assert(recipeItem->type == PS_DATA_METADATA);
+            psMetadata *recipe = recipeItem->data.V;
             psTrace("psModules.config", 3, "Supplementing %s from %s.\n", symbolName, symbolRef);
-            psMetadata *current = psMemIncrRefCounter(psMetadataLookupMetadata(NULL, config->recipes,
-                                  symbolName));
+
+            psMetadata *current = NULL;
+            psMetadataItem *currentItem = psMetadataLookup(config->recipes, symbolName);
+            if (currentItem) {
+                assert(currentItem->type == PS_DATA_METADATA);
+                current = psMemIncrRefCounter(currentItem->data.V);
+            }
+
             current = psMetadataCopy(current, recipe);
             psMetadataAdd(config->recipes, PS_LIST_TAIL, symbolName, PS_DATA_METADATA | PS_META_REPLACE,
@@ -418,7 +439,8 @@
         psMetadata *current = psMetadataLookupMetadata(NULL, config->recipes, symbolName); // The source
         if (current) {
-            recipe = psMetadataLookupMetadata(NULL, current, symbolRef); // The source
-            if (recipe) {
-                // supplement the existing recipe
+            psMetadataItem *recipeItem = psMetadataLookup(current, symbolRef);
+            if (recipeItem) {
+                assert(recipeItem->type == PS_DATA_METADATA);
+                psMetadata *recipe = recipeItem->data.V;
                 psTrace("psModules.config", 3, "Supplementing %s from %s metadata within %s.\n",
                         symbolName, symbolRef, symbolRef);
@@ -457,7 +479,4 @@
     psMetadataItem *item = NULL;    // MD item containing the filename, from recipe iteration
     while ((item = psMetadataGetAndIncrement(recipesIter))) {
-        psMetadata *recipe = NULL;
-        psMetadata *current = NULL;
-
         // type mismatch is a serious error
         if (item->type != PS_DATA_METADATA) {
@@ -465,10 +484,16 @@
         }
         // increment the ref counter to protect the data
-        recipe = psMemIncrRefCounter (item->data.V);
+        psMetadata *recipe = psMemIncrRefCounter (item->data.V);
 
         // if this named recipe exists, supplement it
-        current = psMemIncrRefCounter (psMetadataLookupMetadata (NULL, config->recipes, item->name));
+        psMetadata *current = NULL;
+        psMetadataItem *currentItem = psMetadataLookup(config->recipes, item->name);
+        if (currentItem) {
+            assert(currentItem->type == PS_DATA_METADATA);
+            current = psMemIncrRefCounter(currentItem->data.V);
+        }
         current = psMetadataCopy (current, recipe);
-        psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE, "supplement command-line arguments", current);
+        psMetadataAdd(config->recipes, PS_LIST_TAIL, item->name, PS_DATA_METADATA | PS_META_REPLACE,
+                      "supplement command-line arguments", current);
         psFree(recipe);  // Drop reference
         psFree(current);  // Drop reference
