Index: branches/eam_branches/ipp-20130509/psModules/src/detrend/pmDark.c
===================================================================
--- branches/eam_branches/ipp-20130509/psModules/src/detrend/pmDark.c	(revision 35565)
+++ branches/eam_branches/ipp-20130509/psModules/src/detrend/pmDark.c	(revision 35594)
@@ -383,6 +383,7 @@
       }
       values_set->data[i] = values;
-    }
-
+      psFree(orders);
+    }
+      
     // retrieve the norm vector, if supplied
     psVector *norm       = psMetadataLookupPtr(&mdok, output->analysis, "DARK.NORM");
@@ -433,4 +434,8 @@
                 }
                 pmReadout *readout = inputs->data[r]; // Input readout
+		if ((!readout)||(!readout->image)) {
+		  mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = 0xff;
+		  continue;
+		}		  
                 int yIn = i - readout->row0; // y position on input readout
                 int xIn = j - readout->col0; // x position on input readout
@@ -504,4 +509,16 @@
     psFree(mask);
 
+    for (int i = 0; i < max_orders->n; i++) {
+      psFree(poly_set->data[i]);
+      psArray *values = values_set->data[i];
+      for (int j = 0; j < values->n; j++) {
+	psFree(values->data[j]);
+      }
+      psFree(values_set->data[i]);
+    }
+    psFree(values_set);
+    psFree(poly_set);
+    psFree(logL);
+
     return true;
 }
Index: branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_TRAIL.c
===================================================================
--- branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_TRAIL.c	(revision 35565)
+++ branches/eam_branches/ipp-20130509/psModules/src/objects/models/pmModel_TRAIL.c	(revision 35594)
@@ -169,13 +169,13 @@
         dPAR[PM_PAR_SIGMA]  = 0;	// we don't actually allow this to vary, so we do not need to calculate it
 
-	for (int i = 0; i < 7; i++) {
-	  if (isnan(dPAR[i])) {
-	    fprintf (stderr, "*");
-	  }
-	}
-    }
-    if (isnan(f)) {
-      fprintf (stderr, "!");
-    }
+	//	for (int i = 0; i < 7; i++) {
+	//	  if (isnan(dPAR[i])) {
+	//	    fprintf (stderr, "*");
+	//	  }
+	//	}
+    }
+    //    if (isnan(f)) {
+    //      fprintf (stderr, "!");
+    //    }
     return(f);
 }
