Index: /trunk/psModules/src/pmAstrometry.c
===================================================================
--- /trunk/psModules/src/pmAstrometry.c	(revision 4996)
+++ /trunk/psModules/src/pmAstrometry.c	(revision 4997)
@@ -8,6 +8,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-09-11 22:25:39 $
+*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-09-12 20:38:25 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -47,6 +47,8 @@
 XXX: Is this the correct way to free metadata?
 XXX: Is this the correct way to free database structs?
+ 
+XXX: The meory dereferencing is not quite right with these functions.  If I
+call the alloc functions with non-NULL pointers, there will be memory leaks.
  *****************************************************************************/
-
 static void FPAFree(pmFPA *fpa)
 {
@@ -120,5 +122,5 @@
     tmpReadout->concepts = psMetadataAlloc();
     tmpReadout->parent = cell;
-
+    psMemIncrRefCounter((psPtr) cell);
     if (cell != NULL) {
         cell->readouts = psArrayAdd(cell->readouts, 1, (psPtr) tmpReadout);
@@ -141,4 +143,5 @@
     tmpCell->readouts = psArrayAlloc(0);
     tmpCell->parent = chip;
+    psMemIncrRefCounter((psPtr) chip);
     if (chip != NULL) {
         chip->cells = psArrayAdd(chip->cells, 1, (psPtr) tmpCell);
@@ -165,6 +168,8 @@
     tmpChip->cells = psArrayAlloc(0);
     tmpChip->parent = fpa;
+    psMemIncrRefCounter((psPtr) fpa);
     if (fpa != NULL) {
         fpa->chips = psArrayAdd(fpa->chips, 1, (psPtr) tmpChip);
+        psMemIncrRefCounter((psPtr) tmpChip);
     }
     tmpChip->valid = false;
@@ -189,7 +194,9 @@
     tmpFPA->analysis = psMetadataAlloc();
     tmpFPA->camera = camera;
+    psMemIncrRefCounter((psPtr) camera);
     tmpFPA->chips = psArrayAlloc(0);
     tmpFPA->header = NULL;
     tmpFPA->db = db;
+    psMemIncrRefCounter((psPtr) db);
 
     psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree);
Index: /trunk/psModules/src/pmFlatField.c
===================================================================
--- /trunk/psModules/src/pmFlatField.c	(revision 4996)
+++ /trunk/psModules/src/pmFlatField.c	(revision 4997)
@@ -18,6 +18,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-16 01:10:34 $
+ *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-12 20:38:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -78,10 +78,11 @@
     // Check input image and its mask are not larger than flat image
 
-    if(inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) {
+    if (inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) {
         psError( PS_ERR_BAD_PARAMETER_SIZE, true,
                  PS_ERRORTEXT_pmFlatField_SIZE_INPUT_IMAGE,
                  inImage->numRows, inImage->numCols, flatImage->numRows, flatImage->numCols);
         return false;
-    } else if(inMask->numRows>flatImage->numRows || inMask->numCols > flatImage->numCols) {
+    }
+    if (inMask->numRows > flatImage->numRows || inMask->numCols > flatImage->numCols) {
         psError( PS_ERR_BAD_PARAMETER_SIZE, true,
                  PS_ERRORTEXT_pmFlatField_SIZE_MASK_IMAGE,
Index: /trunk/psModules/src/pmSubtractBias.c
===================================================================
--- /trunk/psModules/src/pmSubtractBias.c	(revision 4996)
+++ /trunk/psModules/src/pmSubtractBias.c	(revision 4997)
@@ -6,6 +6,6 @@
  *  @author GLG, MHPCC
  *
- *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-08-16 01:10:34 $
+ *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-09-12 20:38:25 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -187,7 +187,7 @@
         myPoly = (psPolynomial1D *) fitSpec;
         PS_ASSERT_POLY_NON_NULL(myPoly, NULL);
-        myPoly = psVectorFitPolynomial1D(myPoly, NULL, overscanVector, NULL);
+        myPoly = psVectorFitPolynomial1D(myPoly, NULL, 0, overscanVector, NULL, NULL);
         if (myPoly == NULL) {
-            psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector(): Could not fit a polynomial to the psVector.\n");
+            psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector()(1): Could not fit a polynomial to the psVector.\n");
             return(NULL);
         }
@@ -215,5 +215,5 @@
         mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL);
         if (mySpline == NULL) {
-            psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector(): Could not fit a spline to the psVector.\n");
+            psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector()(2): Could not fit a spline to the psVector.\n");
             return(NULL);
         }
@@ -550,7 +550,7 @@
             if (fit == PM_FIT_POLYNOMIAL) {
                 myPoly = (psPolynomial1D *) fitSpec;
-                myPoly = psVectorFitPolynomial1D(myPoly, NULL, overscanVector, NULL);
+                myPoly = psVectorFitPolynomial1D(myPoly, NULL, 0, overscanVector, NULL, NULL);
                 if (myPoly == NULL) {
-                    psError(PS_ERR_UNKNOWN, false, "Could not fit a polynomial to overscan vector.  Returning in image.\n");
+                    psError(PS_ERR_UNKNOWN, false, "(3) Could not fit a polynomial to overscan vector.  Returning in image.\n");
                     psFree(overscanVector);
                     return(in);
