Index: /trunk/psModules/src/detrend/pmBias.c
===================================================================
--- /trunk/psModules/src/detrend/pmBias.c	(revision 13754)
+++ /trunk/psModules/src/detrend/pmBias.c	(revision 13755)
@@ -298,6 +298,6 @@
                 psImage *overscan = NULL; // Overscan image from iterator
                 while ((overscan = psListGetAndIncrement(iter))) {
-		    // the overscan and image may not be aligned.  pixels->data represents the 
-		    // image row pixels.  
+		    // the overscan and image might not be aligned.  pixels->data represents
+		    // the image row pixels.
                     int diff = overscan->row0 - image->row0; // Offset between the two regions
                     for (int i = PS_MAX(0,diff); i < PS_MIN(image->numRows, overscan->numRows + diff); i++) {
@@ -345,12 +345,16 @@
                 psImage *overscan = NULL; // Overscan image from iterator
                 while ((overscan = psListGetAndIncrement(iter))) {
-                    int diff = image->col0 - overscan->col0; // Offset between the two regions
+		    // the overscan and image might not be aligned.  pixels->data represents
+		    // the image row pixels.
+                    int diff = overscan->col0 - image->col0; // Offset between the two regions
                     for (int i = PS_MAX(0,diff); i < PS_MIN(image->numCols, overscan->numCols + diff); i++) {
-                        // i is column on overscan
+			int I = i - diff;
+                        // i is column on image
+                        // I is column on overscan
                         psVector *values = pixels->data[i];
                         int index = values->n; // Index in the vector
                         values = psVectorRealloc(values, values->n + overscan->numRows);
-                        for (int j = 0; j < overscan->numRows; j++) {
-                            values->data.F32[index++] = overscan->data.F32[j][i];
+                        for (int J = 0; J < overscan->numRows; J++) {
+                            values->data.F32[index++] = overscan->data.F32[J][I];
                         }
                         values->n += overscan->numRows;
