Index: trunk/psModules/src/imcombine/pmSubtractionMatch.c
===================================================================
--- trunk/psModules/src/imcombine/pmSubtractionMatch.c	(revision 15756)
+++ trunk/psModules/src/imcombine/pmSubtractionMatch.c	(revision 15809)
@@ -18,5 +18,4 @@
 #include "pmSubtractionMatch.h"
 
-#define TOL 1.0e-3                      // Tolerance for subtraction solution
 #define KERNEL_MOSAIC 2                 // Half-number of kernel instances in the mosaic image
 
@@ -24,10 +23,11 @@
 
 
-//#define TESTING
+#define TESTING
+//#define TESTING_MEMORY
 
 // Output memory usage information
 static void memCheck(const char *where)
 {
-#ifdef TESTING
+#ifdef TESTING_MEMORY
     psMemBlock **leaks = NULL;
     int numLeaks = psMemCheckLeaks(0, &leaks, NULL, true);
@@ -216,5 +216,4 @@
     psString regionString = NULL;       // String for region
     pmSubtractionStampList *stamps = NULL; // Stamps for matching PSF
-    psVector *solution = NULL;          // Solution to match PSF
     pmSubtractionKernels *kernels = NULL; // Kernel basis functions
     int numCols = ro1->image->numCols, numRows = ro1->image->numRows; // Image dimensions
@@ -261,5 +260,5 @@
                                                            stampSpacing, mode);
             } else if (stampsName && strlen(stampsName) > 0) {
-                stamps = pmSubtractionStampsSetFromFile(stampsName, subMask, region, footprint,
+                stamps = pmSubtractionStampsSetFromFile(stampsName, ro1->image, subMask, region, footprint,
                                                         stampSpacing, mode);
             }
@@ -331,5 +330,5 @@
                 psTrace("psModules.imcombine", 3, "Solving equation...\n");
 
-                if (!pmSubtractionSolveEquation(kernels, stamps, TOL)) {
+                if (!pmSubtractionSolveEquation(kernels, stamps)) {
                     psError(PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");
                     goto MATCH_ERROR;
@@ -360,5 +359,5 @@
             if (numRejected > 0) {
                 psTrace("psModules.imcombine", 3, "Solving equation...\n");
-                if (!pmSubtractionSolveEquation(kernels, stamps, TOL)) {
+                if (!pmSubtractionSolveEquation(kernels, stamps)) {
                     psError(PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");
                     goto MATCH_ERROR;
@@ -413,5 +412,5 @@
             }
 
-#ifdef TESTING
+#if 0
             {
                 // Generate images of the kernel components
@@ -442,4 +441,5 @@
             kernels = NULL;
 
+#if 0
             // Put the solution on the metadata
             {
@@ -460,7 +460,5 @@
                 }
             }
-
-            psFree(solution);
-            solution = NULL;
+#endif
 
             // There is data in the readout now
@@ -496,4 +494,18 @@
 
 
+#ifdef TESTING
+    {
+        psFits *fits = psFitsOpen("convolved1.fits", "w");
+        psFitsWriteImage(fits, NULL, conv1->image, 0, NULL);
+        psFitsClose(fits);
+
+        if (mode == PM_SUBTRACTION_MODE_DUAL) {
+            psFits *fits = psFitsOpen("convolved2.fits", "w");
+            psFitsWriteImage(fits, NULL, conv2->image, 0, NULL);
+            psFitsClose(fits);
+        }
+    }
+#endif
+
     return true;
 
@@ -504,5 +516,4 @@
     psFree(kernels);
     psFree(stamps);
-    psFree(solution);
     psFree(weight);
     return false;
