Index: /trunk/ppStack/src/ppStackArguments.c
===================================================================
--- /trunk/ppStack/src/ppStackArguments.c	(revision 19282)
+++ /trunk/ppStack/src/ppStackArguments.c	(revision 19283)
@@ -152,8 +152,9 @@
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-combine-rej", 0,
                      "Combination rejection thresold (sigma)", NAN);
-    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-mask-val", 0, "Mask value of input bad pixels", NULL);
-    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-mask-bad", 0, "Mask value to give bad pixels", NULL);
-    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-mask-poor", 0, "Mask value to give poor pixels", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask-val", 0, "Mask value of input bad pixels", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask-bad", 0, "Mask value to give bad pixels", NULL);
+    psMetadataAddStr(arguments, PS_LIST_TAIL, "-mask-poor", 0, "Mask value to give poor pixels", NULL);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-threshold-mask", 0, "Threshold for mask deconvolution", NAN);
+    psMetadataAddF32(arguments, PS_LIST_TAIL, "-poor-frac", 0, "Fraction of weight for poor pixels", NAN);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-image-rej", 0,
                      "Pixel rejection fraction threshold for rejecting entire image", NAN);
@@ -233,4 +234,5 @@
     VALUE_ARG_RECIPE_FLOAT("-image-rej",      "IMAGE.REJ",      F32);
     VALUE_ARG_RECIPE_INT("-rows",             "ROWS",           S32, 0);
+    VALUE_ARG_RECIPE_FLOAT("-poor-frac",      "POOR.FRACTION",  F32);
 
     valueArgRecipeStr(arguments, recipe, "-mask-val",  "MASK.VAL",  recipe);
Index: /trunk/ppStack/src/ppStackLoop.c
===================================================================
--- /trunk/ppStack/src/ppStackLoop.c	(revision 19282)
+++ /trunk/ppStack/src/ppStackLoop.c	(revision 19283)
@@ -220,4 +220,5 @@
     float imageRej = psMetadataLookupF32(NULL, recipe, "IMAGE.REJ"); // Maximum fraction of image to reject
                                                                      // before rejecting entire image
+    float poorFrac = psMetadataLookupF32(&mdok, recipe, "POOR.FRACTION"); // Fraction for "poor"
 
     const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics
@@ -410,4 +411,5 @@
     psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator
     int numGood = 0;                    // Number of good frames
+    int numCols = 0, numRows = 0;       // Size of image
     for (int i = 0; i < num; i++) {
         psTrace("ppStack", 2, "Convolving input %d of %d to target PSF....\n", i, num);
@@ -426,4 +428,17 @@
         pmReadout *readout = pmFPAviewThisReadout(view, file->fpa); // Input readout
         psFree(view);
+
+        if (numCols == 0 && numRows == 0) {
+            numCols = readout->image->numCols;
+            numRows = readout->image->numRows;
+        } else if (numCols != readout->image->numCols || numRows != readout->image->numRows) {
+            psError(PS_ERR_UNKNOWN, true, "Sizes of input images don't match: %dx%d vs %dx%d",
+                    readout->image->numCols, readout->image->numRows, numCols, numRows);
+            psFree(globalSources);
+            psFree(indSources);
+            psFree(targetPSF);
+            psFree(rng);
+            return false;
+        }
 
         // Background subtraction, scaling and normalisation is performed automatically by the image matching
@@ -621,29 +636,29 @@
 #ifdef TESTING
             {
-                psImage *pix = psPixelsToMask(NULL, inspect, psRegionSet(0, outRO->image->numCols - 1,
-                                                                         0, outRO->image->numRows - 1), 0xff);
+                psImage *mask = psPixelsToMask(NULL, inspect, psRegionSet(0, numCols - 1, 0, numRows - 1),
+                                               0xff); // Mask image
                 psString name = NULL;           // Name of image
                 psStringAppend(&name, "inspect_%03d.fits", i);
                 psFits *fits = psFitsOpen(name, "w");
                 psFree(name);
-                psFitsWriteImage(fits, NULL, pix, 0, NULL);
-                psFree(pix);
+                psFitsWriteImage(fits, NULL, mask, 0, NULL);
+                psFree(mask);
                 psFitsClose(fits);
             }
 #endif
 
-            psPixels *reject = pmStackReject(inspect, NULL, threshold, subRegions->data[i],
-                                             subKernels->data[i]); // Pixels to reject
+            psPixels *reject = pmStackReject(inspect, numCols, numRows, threshold, poorFrac,
+                                             subRegions->data[i], subKernels->data[i]); // Pixels to reject
 
 #ifdef TESTING
             {
-                psImage *pix = psPixelsToMask(NULL, reject, psRegionSet(0, outRO->image->numCols - 1,
-                                                                        0, outRO->image->numRows - 1), 0xff);
+                psImage *mask = psPixelsToMask(NULL, reject, psRegionSet(0, numCols - 1, 0, numRows - 1),
+                                               0xff); // Mask image
                 psString name = NULL;           // Name of image
                 psStringAppend(&name, "reject_%03d.fits", i);
                 psFits *fits = psFitsOpen(name, "w");
                 psFree(name);
-                psFitsWriteImage(fits, NULL, pix, 0, NULL);
-                psFree(pix);
+                psFitsWriteImage(fits, NULL, mask, 0, NULL);
+                psFree(mask);
                 psFitsClose(fits);
             }
Index: /trunk/ppStack/src/ppStackMatch.c
===================================================================
--- /trunk/ppStack/src/ppStackMatch.c	(revision 19282)
+++ /trunk/ppStack/src/ppStackMatch.c	(revision 19283)
@@ -15,5 +15,5 @@
                      PM_SOURCE_MODE_CR_LIMIT) // Mask to apply to input sources
 
-//#define TESTING                         // Enable debugging output
+#define TESTING                         // Enable debugging output
 
 
