Index: /branches/eam_branches/ipp-20110404/psModules/src/camera/pmFPAWrite.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/camera/pmFPAWrite.c	(revision 31442)
+++ /branches/eam_branches/ipp-20110404/psModules/src/camera/pmFPAWrite.c	(revision 31443)
@@ -690,4 +690,5 @@
     pmHDU *hdu = pmHDUFromCell(cell);   // HDU for cell
     psMetadata *header = psMetadataCopy(NULL, hdu->header); // Header to write
+
     psMetadataAddS32(header, PS_LIST_TAIL, "COVARIANCE.CENTRE.X", PS_META_REPLACE,
                      "Centre of covariance matrix in x", -xMinCovar);
@@ -697,5 +698,9 @@
     // Turn off compression
     int bitpix = fits->options ? fits->options->bitpix : 0; // Desired bits per pixel
+    psFitsScaling scaling = fits->options ? fits->options->scaling : 0; // Current scaling method.
     psFitsCompression *compress = psFitsCompressionGet(fits); // Current compression options
+    
+/*     fprintf(stderr,"Attempting to write chip %s cell %s extension %s with scaling %d\n", */
+/* 	    chipName,cellName,extname,fits->options->scaling); */
     if (!psFitsSetCompression(fits, PS_FITS_COMPRESS_NONE, NULL, 0, 0, 0)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to set FITS compression to NONE");
@@ -708,4 +713,7 @@
     if (fits->options) {
         fits->options->bitpix = 0;
+    }
+    if (fits->options) {
+        fits->options->scaling = psFitsScalingFromString("STDEV_POSITIVE"); // This is a bit of a hack. We don't really have a default value.
     }
 
@@ -732,4 +740,7 @@
         fits->options->bitpix = bitpix;
     }
+    if (fits->options) {
+        fits->options->scaling = scaling;
+    }
     if (!psFitsCompressionApply(fits, compress)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to restore FITS compression");
Index: /branches/eam_branches/ipp-20110404/psModules/src/extras/pmVisualUtils.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/extras/pmVisualUtils.c	(revision 31442)
+++ /branches/eam_branches/ipp-20110404/psModules/src/extras/pmVisualUtils.c	(revision 31443)
@@ -416,10 +416,11 @@
         return;
     } else {
+        int nwritten = 0;
         if (comp->level == PM_DEFAULT_VISUAL_LEVEL) {
 	    sprintf(line,"%*s%-*s %d\n", depth, "", 20 - depth, comp->name, defLevel);
-	    fwrite (line, 1, strlen(line), output);
+	    nwritten = fwrite (line, 1, strlen(line), output);
         } else {
 	    sprintf(line, "%*s%-*s %d\n", depth, "", 20 - depth, comp->name, comp->level);
-	    fwrite (line, 1, strlen(line), output);
+	    nwritten = fwrite (line, 1, strlen(line), output);
         }
     }
Index: /branches/eam_branches/ipp-20110404/psModules/src/imcombine/pmStack.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/imcombine/pmStack.c	(revision 31442)
+++ /branches/eam_branches/ipp-20110404/psModules/src/imcombine/pmStack.c	(revision 31443)
@@ -37,6 +37,6 @@
 # if (0)
 #define TESTING                         // Enable test output
-#define TEST_X 340                       // x coordinate to examine
-#define TEST_Y 938                       // y coordinate to examine
+#define TEST_X 3145                       // x coordinate to examine
+#define TEST_Y 2334                       // y coordinate to examine
 #define TEST_RADIUS 0.5                 // Radius to examine
 # endif
Index: /branches/eam_branches/ipp-20110404/psModules/src/imcombine/pmStackReject.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/imcombine/pmStackReject.c	(revision 31442)
+++ /branches/eam_branches/ipp-20110404/psModules/src/imcombine/pmStackReject.c	(revision 31443)
@@ -125,4 +125,11 @@
     PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(threshold, 0.0, NULL);
     PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(threshold, 1.0, NULL);
+
+    if (!subRegions || !subKernels) {
+      psTrace("psModules.imcombine",2,"Do not have the necessary kernels and regions, returning input pixels.");
+      psPixels *out = psPixelsCopy(NULL,in);
+      return out;
+    }
+    
     PS_ASSERT_ARRAY_NON_NULL(subRegions, NULL);
     PS_ASSERT_ARRAY_NON_NULL(subKernels, NULL);
Index: /branches/eam_branches/ipp-20110404/psModules/src/objects/pmFootprintAssignPeaks.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/objects/pmFootprintAssignPeaks.c	(revision 31442)
+++ /branches/eam_branches/ipp-20110404/psModules/src/objects/pmFootprintAssignPeaks.c	(revision 31443)
@@ -35,10 +35,8 @@
     assert (peaks->n == 0 || psMemCheckPeak(peaks->data[0]));
     
-    if (footprints->n == 0) {
-	if (peaks->n > 0) {
-	    return psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Your list of footprints is empty");
-	}
+    if ((footprints->n == 0) && (peaks->n == 0)) {
 	return PS_ERR_NONE;
     }
+
     /*
      * Create an image filled with the object IDs, and use it to assign pmPeaks to the
@@ -59,6 +57,5 @@
 	
 	if (ids) { assert (x >= 0 && x < numCols && y >= 0 && y < numRows);}
-	int id = ids ? ids->data.S32[y][x - col0] : 0;
-	// XXX I think the '[x - col0]' above is just wrong (should be [x], but never gets triggerd.
+	int id = ids ? ids->data.S32[y][x] : 0;
 
 	if (id == 0) {			// peak isn't in a footprint, so make one for it
Index: /branches/eam_branches/ipp-20110404/psModules/src/objects/pmFootprintCullPeaks.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/objects/pmFootprintCullPeaks.c	(revision 31442)
+++ /branches/eam_branches/ipp-20110404/psModules/src/objects/pmFootprintCullPeaks.c	(revision 31443)
@@ -102,5 +102,6 @@
 	float beta = nsigma_delta * ALPHA;
 	float beta2 = PS_SQR(beta);
-	int nBins = sqrt(4.0*(maxFlux - min_threshold)/beta2) + 10; // let's be extra generous
+	float value = 4.0*(maxFlux - min_threshold)/beta2;
+	int nBins = (value > 1.0) ? sqrt(value) + 10 : 10; // let's be extra generous
 
 	// create a vector to store the threshold bins used for each peak
Index: /branches/eam_branches/ipp-20110404/psModules/src/objects/pmFootprintIDs.c
===================================================================
--- /branches/eam_branches/ipp-20110404/psModules/src/objects/pmFootprintIDs.c	(revision 31442)
+++ /branches/eam_branches/ipp-20110404/psModules/src/objects/pmFootprintIDs.c	(revision 31443)
@@ -66,6 +66,4 @@
 
    if (footprints->n == 0) {
-       // XXX this was an error, but is an allowed condition -- NULL returned image means no footprints for any peaks
-       // psError(PS_ERR_BAD_PARAMETER_SIZE, true, "You didn't provide any footprints");
        return NULL;
    }
