Index: /trunk/psModules/src/camera/pmFPARead.c
===================================================================
--- /trunk/psModules/src/camera/pmFPARead.c	(revision 16396)
+++ /trunk/psModules/src/camera/pmFPARead.c	(revision 16397)
@@ -43,4 +43,38 @@
 // File-static functions
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// Return pointer to appropriate value for tracking scans
+static int *readoutScansByType(pmReadout *readout, // Readout of interest
+                               fpaReadType type // Type of image
+    )
+{
+    switch (type) {
+      case FPA_READ_TYPE_IMAGE:
+        return &readout->imageScan;
+      case FPA_READ_TYPE_MASK:
+        return &readout->maskScan;
+      case FPA_READ_TYPE_WEIGHT:
+        return &readout->weightScan;
+      default:
+        psAbort("Unknown read type: %x\n", type);
+    }
+}
+
+// Return pointer to appropriate image
+static psImage **readoutImageByType(pmReadout *readout, // Readout of interest
+                                    fpaReadType type // Type of image
+    )
+{
+    switch (type) {
+      case FPA_READ_TYPE_IMAGE:
+        return &readout->image;
+      case FPA_READ_TYPE_MASK:
+        return &readout->mask;
+      case FPA_READ_TYPE_WEIGHT:
+        return &readout->weight;
+      default:
+        psAbort("Unknown read type: %x\n", type);
+    }
+}
 
 // Determine number of readouts in the FITS file
@@ -116,18 +150,5 @@
     assert(readout);
 
-    psImage *image;                     // Appropriate image from readout
-    switch (type) {
-      case FPA_READ_TYPE_IMAGE:
-        image = readout->image;
-        break;
-      case FPA_READ_TYPE_MASK:
-        image = readout->mask;
-        break;
-      case FPA_READ_TYPE_WEIGHT:
-        image = readout->weight;
-        break;
-      default:
-        psAbort("Unknown read type: %x\n", type);
-    }
+    psImage *image = *readoutImageByType(readout, type); // Appropriate image from readout
 
     // Header and concepts have been read by a call to cellNumReadouts(), so we can just assume they're there.
@@ -167,43 +188,14 @@
     }
 
-
     // Calculate the segment offset and upper limit
-    if (readdir == 1) {
-        // Reading rows
-        if (numScans == 0) {
-            *next = trimsec->x0;
-        } else {
-            *next = image ? readout->row0 + numScans - overlap : 0;
-        }
-        *last = trimsec->y1;
+    if (numScans == 0) {
+        *next = (readdir == 1) ? trimsec->x0 : trimsec->y0;
     } else {
-        // Reading cols
-        if (numScans == 0) {
-            *next = trimsec->y0;
-        } else {
-            *next = image ? readout->col0 + numScans - overlap : 0;
-        }
-        *last = trimsec->x1;
-    }
+        *next = image ? *readoutScansByType(readout, type) + numScans - overlap : 0;
+    }
+    *last = (readdir == 1) ? trimsec->y1 : trimsec->x1;
 
     return true;
 }
-
-static psImage **readoutImageByType(pmReadout *readout, // Readout of interest
-                                    fpaReadType type // Type of image
-    )
-{
-    switch (type) {
-      case FPA_READ_TYPE_IMAGE:
-        return &readout->image;
-      case FPA_READ_TYPE_MASK:
-        return &readout->mask;
-      case FPA_READ_TYPE_WEIGHT:
-        return &readout->weight;
-      default:
-        psAbort("Unknown read type: %x\n", type);
-    }
-}
-
 
 static bool readoutMore(pmReadout *readout, // Readout of interest
@@ -469,5 +461,11 @@
     }
 
+    // Update number of scans read
+    int *scansTracker = readoutScansByType(readout, type); // Tracker for how many scans have been read
+    *scansTracker = next;
+
     // Calculate limits, adjust readout->row0,col0
+    // XXX Should row0,col0 be adjusted, since they are used for astrometry???
+    // Just moved to using the "scansTracker" for tracking position in chunk reads, so row0,col0 not required
     if (readdir == 1) {
         // Reading rows
