Index: trunk/psastro/src/psastroChipAstrom.c
===================================================================
--- trunk/psastro/src/psastroChipAstrom.c	(revision 19514)
+++ trunk/psastro/src/psastroChipAstrom.c	(revision 20269)
@@ -4,4 +4,5 @@
 bool psastroChipAstrom (pmConfig *config) {
 
+    bool status;
     pmChip *chip = NULL;
     pmCell *cell = NULL;
@@ -9,5 +10,5 @@
 
     // select the current recipe
-    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSASTRO_RECIPE);
+    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSASTRO_RECIPE);
     if (!recipe) {
         psError(PSASTRO_ERR_CONFIG, true, "Can't find PSASTRO recipe");
@@ -16,5 +17,5 @@
 
     // select the input data sources
-    pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
+    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSASTRO.INPUT");
     if (!input) {
         psError(PSASTRO_ERR_CONFIG, true, "Can't find input data");
@@ -43,9 +44,9 @@
 
                 // select the raw objects for this readout
-                psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");
+                psArray *rawstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.RAWSTARS");
                 if (rawstars == NULL) { continue; }
 
                 // select the raw objects for this readout
-                psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");
+                psArray *refstars = psMetadataLookupPtr (&status, readout->analysis, "PSASTRO.REFSTARS");
                 if (refstars == NULL) { continue; }
 
@@ -59,5 +60,11 @@
 
                 // save WCS and analysis metadata in update header
-                psMetadata *updates = psMetadataAlloc();
+		// (pull or create local view to entry on readout->analysis)
+		psMetadata *updates = psMetadataLookupMetadata (&status, readout->analysis, "PSASTRO.HEADER");
+		if (!updates) {
+		    updates = psMetadataAlloc ();
+		    psMetadataAddMetadata (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_META_REPLACE, "psastro header stats", updates);
+		    psFree (updates);
+		}
 
                 // XXX update the header with info to reflect the failure
@@ -65,5 +72,4 @@
                     readout->data_exists = false;
                     psLogMsg ("psastro", 3, "failed to find a solution\n");
-                    psFree (updates);
                     continue;
                 }
@@ -72,5 +78,4 @@
                     readout->data_exists = false;
                     psLogMsg ("psastro", 3, "failed to find a solution\n");
-                    psFree (updates);
                     continue;
                 }
@@ -82,11 +87,9 @@
 
                 pmAstromWriteWCS (updates, fpa, chip, NONLIN_TOL);
-                psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.HEADER",  PS_DATA_METADATA, "psastro header stats", updates);
-                psFree (updates);
 
                 if (psTraceGetLevel("psastro.dump") > 0) {
 
                     char *filename = NULL;
-                    char *chipname = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME");
+                    char *chipname = psMetadataLookupStr (&status, chip->concepts, "CHIP.NAME");
 
                     psStringAppend (&filename, "rawstars.ch.%s.dat", chipname);
