Index: trunk/pswarp/src/pswarpLoop.c
===================================================================
--- trunk/pswarp/src/pswarpLoop.c	(revision 13661)
+++ trunk/pswarp/src/pswarpLoop.c	(revision 13686)
@@ -68,4 +68,5 @@
             psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input FPA.");
             psFree(view);
+            psFree(stats);
             return false;
         }
@@ -87,4 +88,5 @@
                 psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel chip astrometry for input FPA.");
                 psFree(view);
+                psFree(stats);
                 return false;
             }
@@ -94,4 +96,5 @@
                 psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for input FPA.");
                 psFree(view);
+                psFree(stats);
                 return false;
             }
@@ -106,19 +109,51 @@
             // process each of the readouts
             pmReadout *readout;
-            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
-                pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
-                if (! readout->data_exists) { continue; }
+            while ((readout = pmFPAviewNextReadout(view, input->fpa, 1)) != NULL) {
+                pmFPAfileIOChecks(config, view, PM_FPA_BEFORE);
+                if (!readout->data_exists) {
+                    continue;
+                }
 
-                // XXX _Opt version uses locally-linear map
-                // pswarpTransformReadout (output, readout, config);
-                pswarpTransformReadout_Opt (output, readout, config);
+                pswarpTransformReadout_Opt(output, readout, config);
 
-                pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
+                pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
             }
+            pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
+        }
+        pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
+    }
 
-            pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
-        }
-        pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
+    pmCell *outCell = output->parent;   // Output cell
+    pmChip *outChip = outCell->parent;  // Output chip
+    pmFPA *outFPA = outChip->parent;    // Output FPA
+
+    if (!pmFPACopyConcepts(output->parent->parent->parent, input->fpa)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to copy concepts from input to output.");
+        psFree(stats);
+        psFree(view);
+        return false;
     }
+
+
+    // XXX Hack so that INSTRUME header keyword and the like are not updated properly
+    // If INSTRUME (etc) is updated, then the FITS file with the warped image will be often
+    // recognised as coming from the old camera, not the new, warped camera.
+    // The proper solution to this, I believe, would be to define a skycell derivative of the
+    // old camera, so that the skycell can be recognised as coming from the old camera (and would
+    // also therefore inherit all its recipes, which would be good), rather than having a completely
+    // different camera.  That will take some work; the below solution should be good enough for now.
+    {
+        psMetadataItem *item;           // Concepts item to update
+
+        item = psMetadataLookup(outFPA->concepts, "FPA.INSTRUMENT");
+        psFree(item->data.V);
+        item->data.V = NULL;
+
+        item = psMetadataLookup(outFPA->concepts, "FPA.DETECTOR");
+        psFree(item->data.V);
+        item->data.V = NULL;
+    }
+
+
 
     // Perform statistics on the output image
