Index: trunk/psModules/src/imcombine/pmStackReject.c
===================================================================
--- trunk/psModules/src/imcombine/pmStackReject.c	(revision 16402)
+++ trunk/psModules/src/imcombine/pmStackReject.c	(revision 16403)
@@ -11,6 +11,5 @@
 #define PIXEL_LIST_BUFFER 100           // Number of pixels to add to list at a time
 
-psPixels *pmStackReject(const psPixels *in, float threshold, const psArray *regions,
-                        const psArray *solutions, const pmSubtractionKernels *kernels)
+psPixels *pmStackReject(const psPixels *in, float threshold, const psArray *regions, const psArray *kernels)
 {
     PS_ASSERT_PIXELS_NON_NULL(in, NULL);
@@ -18,7 +17,6 @@
     PS_ASSERT_FLOAT_LESS_THAN_OR_EQUAL(threshold, 1.0, NULL);
     PS_ASSERT_ARRAY_NON_NULL(regions, NULL);
-    PS_ASSERT_ARRAY_NON_NULL(solutions, NULL);
-    PS_ASSERT_ARRAYS_SIZE_EQUAL(regions, solutions, NULL);
-    PS_ASSERT_PTR_NON_NULL(kernels, NULL);
+    PS_ASSERT_ARRAY_NON_NULL(kernels, NULL);
+    PS_ASSERT_ARRAYS_SIZE_EQUAL(regions, kernels, NULL);
 
     // Get the original image size
@@ -26,4 +24,5 @@
     int numCols = 0, numRows = 0;       // Size of original image
     int minCols = INT_MAX, minRows = INT_MAX; // Minimum coordinate for image --- should be 0,0
+    int size = 0;                       // Size of kernel
     for (int i = 0; i < numRegions; i++) {
         psRegion *region = regions->data[i]; // Region of interest
@@ -39,4 +38,13 @@
         if (region->y1 > numRows) {
             numRows = region->y1;
+        }
+
+        pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest
+        if (size == 0) {
+            size = kernel->size;
+        } else if (kernel->size != size) {
+            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Kernel sizes are not identical: %d vs %d",
+                    size, kernel->size);
+            return NULL;
         }
     }
@@ -57,5 +65,6 @@
     for (int i = 0; i < numRegions; i++) {
         psRegion *region = regions->data[i]; // Region of interest
-        if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernels, true)) {
+        pmSubtractionKernels *kernel = kernels->data[i]; // Kernel of interest
+        if (!pmSubtractionConvolve(convRO, NULL, inRO, NULL, NULL, 0, region, kernel, true)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to convolve mask image in region %d.", i);
             psFree(convRO);
@@ -70,6 +79,6 @@
         float xNorm = (region->x0 + 0.5 * (region->x1 - region->x0) - numCols/2.0) / (float)numCols;
         float yNorm = (region->y0 + 0.5 * (region->y1 - region->y0) - numRows/2.0) / (float)numRows;
-        psImage *kernel = pmSubtractionKernelImage(kernels, xNorm, yNorm, false);
-        if (!kernel) {
+        psImage *image = pmSubtractionKernelImage(kernel, xNorm, yNorm, false);
+        if (!image) {
             psError(PS_ERR_UNKNOWN, false, "Unable to generate kernel image.");
             psFree(convRO);
@@ -78,10 +87,10 @@
         }
         float sum = 0.0;
-        for (int y = 0; y < kernel->numRows; y++) {
-            for (int x = 0; x < kernel->numCols; x++) {
-                sum += kernel->data.F32[y][x];
+        for (int y = 0; y < image->numRows; y++) {
+            for (int x = 0; x < image->numCols; x++) {
+                sum += image->data.F32[y][x];
             }
         }
-        psFree(kernel);
+        psFree(image);
 
         psImage *subConv = psImageSubset(convRO->image, *region); // Sub-image of convolved image
@@ -103,7 +112,6 @@
     psFree(convolved);
 
-    // Now, we want to convolve the original pixels properly
+    // Now, grow the mask to include everything that touches a bad pixel in the convolution
     mask = psPixelsToMask(NULL, bad, psRegionSet(0, numCols, 0, numRows), 0xff);
-    int size = kernels->size;           // Size of kernels
     for (int i = 0; i < bad->n; i++) {
         int xPix = bad->data[i].x, yPix = bad->data[i].y; // Coordinates of interest
