Index: /trunk/psModules/src/camera/pmFPAFlags.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAFlags.c	(revision 29934)
+++ /trunk/psModules/src/camera/pmFPAFlags.c	(revision 29935)
@@ -49,4 +49,54 @@
 }
 
+bool pmReadoutSetFileStatus(pmReadout *readout, bool status)
+{
+    PS_ASSERT_PTR_NON_NULL(readout, false);
+
+    readout->file_exists = status;
+    return true;
+}
+
+bool pmFPAviewSetFileStatus (pmFPA *fpa, const pmFPAview *view, bool status) {
+
+    PS_ASSERT_PTR_NON_NULL(fpa, false);
+    PS_ASSERT_PTR_NON_NULL(view, false);
+
+    if (view->chip == -1) {
+	bool set = pmFPASetFileStatus (fpa, status);
+        return set;
+    }
+
+    if (view->chip >= fpa->chips->n) {
+        psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %ld", view->chip, fpa->chips->n);
+        return false;
+    }
+    pmChip *chip = fpa->chips->data[view->chip];
+
+    if (view->cell == -1) {
+        bool set = pmChipSetFileStatus (chip, status);
+        return set;
+    }
+
+    if (view->cell >= chip->cells->n) {
+        psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %ld", view->cell, chip->cells->n);
+        return false;
+    }
+    pmCell *cell = chip->cells->data[view->cell];
+
+    if (view->readout == -1) {
+        bool set = pmCellSetFileStatus (cell, status);
+        return set;
+    }
+
+    if (view->readout >= cell->readouts->n) {
+        psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouds->n == %ld", view->readout, cell->readouts->n);
+        return false;
+    }
+    pmReadout *readout = cell->readouts->data[view->readout];
+
+    bool set = pmReadoutSetFileStatus (readout, status);
+    return set;
+}
+
 bool pmFPACheckFileStatus(const pmFPA *fpa)
 {
@@ -125,7 +175,57 @@
     for (int i = 0; i < cell->readouts->n; i++) {
         pmReadout *readout = cell->readouts->data[i];
-        readout->data_exists = status;
-    }
-    return true;
+        pmReadoutSetDataStatus(readout, status);
+    }
+    return true;
+}
+
+bool pmReadoutSetDataStatus (pmReadout *readout, bool status)
+{
+    PS_ASSERT_PTR_NON_NULL(readout, false);
+
+    readout->data_exists = status;
+    return true;
+}
+
+bool pmFPAviewSetDataStatus (pmFPA *fpa, const pmFPAview *view, bool status) {
+
+    PS_ASSERT_PTR_NON_NULL(fpa, false);
+    PS_ASSERT_PTR_NON_NULL(view, false);
+
+    if (view->chip == -1) {
+	bool set = pmFPASetDataStatus (fpa, status);
+        return set;
+    }
+
+    if (view->chip >= fpa->chips->n) {
+        psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %ld", view->chip, fpa->chips->n);
+        return false;
+    }
+    pmChip *chip = fpa->chips->data[view->chip];
+
+    if (view->cell == -1) {
+        bool set = pmChipSetDataStatus (chip, status);
+        return set;
+    }
+
+    if (view->cell >= chip->cells->n) {
+        psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %ld", view->cell, chip->cells->n);
+        return false;
+    }
+    pmCell *cell = chip->cells->data[view->cell];
+
+    if (view->readout == -1) {
+        bool set = pmCellSetDataStatus (cell, status);
+        return set;
+    }
+
+    if (view->readout >= cell->readouts->n) {
+        psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouds->n == %ld", view->readout, cell->readouts->n);
+        return false;
+    }
+    pmReadout *readout = cell->readouts->data[view->readout];
+
+    bool set = pmReadoutSetDataStatus (readout, status);
+    return set;
 }
 
Index: /trunk/psModules/src/camera/pmFPAFlags.h
===================================================================
--- /trunk/psModules/src/camera/pmFPAFlags.h	(revision 29934)
+++ /trunk/psModules/src/camera/pmFPAFlags.h	(revision 29935)
@@ -34,4 +34,8 @@
                         );
 
+bool pmReadoutSetFileStatus(pmReadout *readout, bool status);
+
+bool pmFPAviewSetFileStatus (pmFPA *fpa, const pmFPAview *view, bool status);
+
 // Functions to check the file_exists flags
 
@@ -65,4 +69,7 @@
                         );
 
+bool pmReadoutSetDataStatus (pmReadout *readout, bool status);
+
+bool pmFPAviewSetDataStatus (pmFPA *fpa, const pmFPAview *view, bool status);
 
 // Functions the check the data_exists flags
Index: /trunk/psModules/src/camera/pmFPAfileIO.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAfileIO.c	(revision 29934)
+++ /trunk/psModules/src/camera/pmFPAfileIO.c	(revision 29935)
@@ -135,7 +135,4 @@
     PS_ASSERT_PTR_NON_NULL(view, false);
 
-    // an internal file should not be sent here (should not be left on config->files)
-    PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
-
     // skip the following states
     if (file->state & PM_FPA_STATE_INACTIVE) {
@@ -143,4 +140,8 @@
         return true;
     }
+
+    // an active internal file should not be sent here (should not be left on config->files)
+    PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
+
     if (file->mode != PM_FPA_MODE_READ) {
         psTrace("psModules.camera", 6, "skip read for %s, mode is not READ", file->name);
@@ -258,11 +259,12 @@
         return true;
     }
+
+    // an active internal file should not be returned to here
+    PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
+
     if (file->mode != PM_FPA_MODE_WRITE) {
         psTrace("psModules.camera", 6, "skip create for non-write file %s", file->name);
         return true;
     }
-
-    // an internal file should not be returned to here
-    PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
 
     // get the current level
@@ -335,13 +337,10 @@
     }
 
+    // an ACTIVE internal file should not be sent here
+    PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
+
     if (file->mode != PM_FPA_MODE_WRITE) {
         psTrace("psModules.camera", 6, "skip write for %s, mode is not WRITE", file->name);
         return true;
-    }
-
-    // an internal file should not be returned to here
-    if (file->mode == PM_FPA_MODE_INTERNAL) {
-        psError(PS_ERR_IO, true, "File is mode PM_FPA_MODE_INTERNAL");
-        return false;
     }
 
@@ -523,7 +522,4 @@
     PS_ASSERT_PTR_NON_NULL(view, false);
 
-    // an internal file should not be sent here (should not be left on config->files)
-    PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
-
     // skip the following states
     if (file->state & PM_FPA_STATE_INACTIVE) {
@@ -531,8 +527,12 @@
         return true;
     }
+
     if (file->state == PM_FPA_STATE_CLOSED) {
         psTrace("psModules.camera", 6, "skip close for %s, files is closed", file->name);
         return true;
     }
+
+    // an active internal file should not be sent here (should not be left on config->files)
+    PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
 
     // is current level == open level?
@@ -596,11 +596,11 @@
     PS_ASSERT_PTR_NON_NULL(view, false);
 
-    // an internal file should not be sent here (should not be left on config->files)
-    PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
-
     if (file->state & PM_FPA_STATE_INACTIVE) {
         psTrace("psModules.camera", 6, "skip free for %s, files is inactive", file->name);
         return true;
     }
+
+    // an active internal file should not be sent here (should not be left on config->files)
+    PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
 
     // get the current level
@@ -746,5 +746,5 @@
     }
 
-    // these are programming errors
+    // an ACTIVE internal file should not be sent here
     PS_ASSERT(file->mode != PM_FPA_MODE_NONE, false);
     PS_ASSERT(file->mode != PM_FPA_MODE_INTERNAL, false);
Index: /trunk/psModules/src/config/pmConfigDump.c
===================================================================
--- /trunk/psModules/src/config/pmConfigDump.c	(revision 29934)
+++ /trunk/psModules/src/config/pmConfigDump.c	(revision 29935)
@@ -150,5 +150,12 @@
     }
 
-    if (!psMetadataConfigWrite(config->user, resolved)) {
+    // check for Metadata compression options:
+    char *compressMode;
+    bool status = false;
+    if (config->camera) {
+	compressMode = psMetadataLookupStr(&status, config->camera, "METADATA.COMPRESSION");
+    }
+
+    if (!psMetadataConfigWrite(config->user, resolved, compressMode)) {
         psError(psErrorCodeLast(), false, "Unable to dump configuration to %s", filename);
         psFree(resolved);
Index: /trunk/psModules/src/detrend/pmNonLinear.c
===================================================================
--- /trunk/psModules/src/detrend/pmNonLinear.c	(revision 29934)
+++ /trunk/psModules/src/detrend/pmNonLinear.c	(revision 29935)
@@ -332,7 +332,4 @@
 	return(0.0);
     }
-/*     if (flux > correction_fluxes->data.F32[bin]) { */
-/* 	return(0.0); */
-/*     } */
   
     for (int i = 0; i < correction_fluxes->n - 1; i++) {
@@ -347,16 +344,7 @@
     }
 
-/*   PS_BIN_FOR_VALUE(bin,correction_fluxes,flux); */
-/*   if ((bin < 0)||(bin > correction_fluxes->n)) { */
-/*     return(1.0); */
-/*   } */
-  
-/*   PS_BIN_INTERPOLATE(result,correction_fluxes,correction_factors,bin,flux); */
     if (!isfinite(result)) {
 	result = 0.0;
     }
-/*     if (result <= 0) { */
-/* 	result = 1.0; */
-/*     } */
     return(result);
 }
@@ -372,7 +360,4 @@
 	return(0.0);
     }
-/*     if (flux > correction_fluxes->data.F32[bin]) { */
-/* 	return(0.0); */
-/*     } */
 
     for (int i = 0; i < correction_fluxes->n - 1; i++) {
@@ -389,19 +374,7 @@
     }
 
-/*   PS_BIN_FOR_VALUE(bin,correction_fluxes,flux); */
-/*   if ((bin < 0)||(bin > correction_fluxes->n)) { */
-/*     return(1.0); */
-/*   } */
-  
-/*   PS_BIN_INTERPOLATE(result,correction_fluxes,correction_factors,bin,flux); */
     if (!isfinite(result)) {
 	result = 0.0;
     }
-/*     if (result <= 0) { */
-/* 	result = 1.0; */
-/*     } */
     return(result);
 }
-
-  
-  
Index: /trunk/psModules/src/objects/pmSource.c
===================================================================
--- /trunk/psModules/src/objects/pmSource.c	(revision 29934)
+++ /trunk/psModules/src/objects/pmSource.c	(revision 29935)
@@ -189,6 +189,6 @@
     // pixels.  Modifying these pixels (ie, subtracting the model) will affect the pixels seen
     // by all copies.
-    source->pixels   = psImageCopyView(NULL, in->pixels);
-    source->variance   = psImageCopyView(NULL, in->variance);
+    source->pixels   = in->pixels   ? psImageCopyView(NULL, in->pixels)   : NULL;
+    source->variance = in->variance ? psImageCopyView(NULL, in->variance) : NULL;
     source->maskView = in->maskView ? psImageCopyView(NULL, in->maskView) : NULL;
 
Index: /trunk/psModules/src/objects/pmSourcePhotometry.c
===================================================================
--- /trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 29934)
+++ /trunk/psModules/src/objects/pmSourcePhotometry.c	(revision 29935)
@@ -107,5 +107,5 @@
     // XXX handle negative flux, low-significance
     if (model->dparams->data.F32[PM_PAR_I0] > 0) {
-        SN = model->params->data.F32[PM_PAR_I0] / model->dparams->data.F32[PM_PAR_I0];
+        SN = fabs(model->params->data.F32[PM_PAR_I0] / model->dparams->data.F32[PM_PAR_I0]);
         source->errMag = 1.0 / SN;
     } else {
@@ -331,5 +331,5 @@
     }
     if (apFluxOut) *apFluxOut = apFlux;
-    if (apFluxErr) *apFluxErr = sqrt(apFluxVar);
+    if (apFluxErr) *apFluxErr = sqrt(fabs(apFluxVar));
 
     if (apFlux <= 0) {
