Index: /trunk/psModules/src/camera/pmHDUGenerate.c
===================================================================
--- /trunk/psModules/src/camera/pmHDUGenerate.c	(revision 9985)
+++ /trunk/psModules/src/camera/pmHDUGenerate.c	(revision 9986)
@@ -303,5 +303,5 @@
     int numReadouts = -1;               // Number of readouts
     psElemType imageType = 0;           // Type of readout images
-    psElemType maskType = 0;   // Type of readout masks
+    psElemType maskType = 0;            // Type of readout masks
     psElemType weightType = 0;          // Type of readout weights
     {
@@ -324,11 +324,11 @@
                 }
 
-                if (readout->image) {
+                if (!hdu->images && readout->image) {
                     imageType = checkTypes(imageType, readout->image->type.type);
                 }
-                if (readout->mask) {
+                if (!hdu->masks && readout->mask) {
                     maskType = checkTypes(maskType, readout->mask->type.type);
                 }
-                if (readout->weight) {
+                if (!hdu->weights && readout->weight) {
                     weightType = checkTypes(weightType, readout->weight->type.type);
                 }
Index: /trunk/psModules/src/detrend/pmMaskBadPixels.c
===================================================================
--- /trunk/psModules/src/detrend/pmMaskBadPixels.c	(revision 9985)
+++ /trunk/psModules/src/detrend/pmMaskBadPixels.c	(revision 9986)
@@ -148,4 +148,5 @@
     float mean = stats->sampleMean;     // Mean value
     float stdev = stats->sampleStdev;   // Standard deviation
+    psFree(stats);
 
     psImage *badpix = psImageAlloc(suspects->numCols, suspects->numRows, PS_TYPE_MASK); // Bad pixel mask
