Index: branches/pap/psLib/src/imageops/psImageMapFit.c
===================================================================
--- branches/pap/psLib/src/imageops/psImageMapFit.c	(revision 23948)
+++ branches/pap/psLib/src/imageops/psImageMapFit.c	(revision 25027)
@@ -73,5 +73,8 @@
 
         // XXX does ROBUST_MEDIAN work with weight?
-        psVectorStats(map->stats, f, NULL, mask, maskValue);
+        if (!psVectorStats(map->stats, f, NULL, mask, maskValue)) {
+	    psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
+	    return false;
+	}
 
         map->map->data.F32[0][0]   = psStatsGetValue(map->stats, mean);
@@ -305,6 +308,5 @@
 # endif
 
-    if (!psMatrixGJSolveF32(A, B)) {
-        psAbort ("failed on linear equations");
+    if (!psMatrixGJSolve(A, B)) {
         psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations.  Returning NULL.\n");
         psFree (A);
@@ -574,9 +576,9 @@
     }
 
-    if (!psMatrixGJSolveF32(A, B)) {
-        psAbort ("failed on linear equations");
-        psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations.  Returning NULL.\n");
+    if (!psMatrixGJSolve(A, B)) {
+        psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations.\n");
         psFree (A);
         psFree (B);
+	psFree (Empty);
         return false;
     }
@@ -722,9 +724,9 @@
     }
 
-    if (!psMatrixGJSolveF32(A, B)) {
-        psAbort ("failed on linear equations");
-        psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations.  Returning NULL.\n");
+    if (!psMatrixGJSolve(A, B)) {
+        psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations..\n");
         psFree (A);
         psFree (B);
+	psFree (Empty);
         return false;
     }
@@ -739,7 +741,6 @@
 
     for (int m = 0; m < Nx; m++) {
-        int I = m; // XXX I'm not entirely sure about this; it wasn't set for this scope --- PAP.
-        map->map->data.F32[0][m] = B->data.F32[I];
-        map->error->data.F32[0][m] = sqrt(A->data.F32[I][I]);
+        map->map->data.F32[0][m] = B->data.F32[m];
+        map->error->data.F32[0][m] = sqrt(A->data.F32[m][m]);
     }
 
