Index: trunk/psModules/src/astrom/pmAstrometryObjects.c
===================================================================
--- trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 40082)
+++ trunk/psModules/src/astrom/pmAstrometryObjects.c	(revision 40083)
@@ -1111,4 +1111,6 @@
     }
 
+    pmAstromVisualPlotTweak (xHist, yHist, xBin, yBin);
+
     // smooth histgram vector with gaussian of 1sigma = radius
     psVector *xHistNew = psVectorSmooth(NULL, xHist, tweakSmooth, tweakNsigma);
Index: trunk/psModules/src/astrom/pmAstrometryVisual.c
===================================================================
--- trunk/psModules/src/astrom/pmAstrometryVisual.c	(revision 40082)
+++ trunk/psModules/src/astrom/pmAstrometryVisual.c	(revision 40083)
@@ -1045,5 +1045,5 @@
     if (!plotTweak) return true;
     if (!pmVisualTestLevel("psastro.plot13", 1)) return true;
-    if (!pmVisualInitWindow(&kapa1, "psastro:plots")) return false;
+    if (!pmVisualInitWindow(&kapa3, "psastro:plots")) return false;
 
     Graphdata graphdata;
@@ -1066,16 +1066,16 @@
 
     // set up plot information
-    KapaClearPlots(kapa1);
+    KapaClearPlots(kapa3);
     KapaInitGraph(&graphdata);
 
     // plot the X histogram
     pmVisualScaleGraphdata(&graphdata, xIndices, xHist, false);
-    KapaSetSection(kapa1, &section1);
-    KapaSetLimits (kapa1, &graphdata);
-    KapaSetFont(kapa1, "helvetica", 14);
-    KapaBox(kapa1, &graphdata);
-    KapaSendLabel (kapa1, "X offset Bin", KAPA_LABEL_XM);
-    KapaSendLabel (kapa1, "Number of Sources", KAPA_LABEL_YM);
-    KapaSendLabel (kapa1, "Horizontal Profile",
+    KapaSetSection(kapa3, &section1);
+    KapaSetLimits (kapa3, &graphdata);
+    KapaSetFont(kapa3, "helvetica", 14);
+    KapaBox(kapa3, &graphdata);
+    KapaSendLabel (kapa3, "X offset Bin", KAPA_LABEL_XM);
+    KapaSendLabel (kapa3, "Number of Sources", KAPA_LABEL_YM);
+    KapaSendLabel (kapa3, "Horizontal Profile",
                    KAPA_LABEL_XP);
     graphdata.style = 1;
@@ -1084,7 +1084,7 @@
     graphdata.color = KapaColorByName ("black");
 
-    KapaPrepPlot (kapa1, xHist->n, &graphdata);
-    KapaPlotVector (kapa1, xHist->n, xIndices->data.F32, "x");
-    KapaPlotVector (kapa1, xHist->n, xHist->data.F32, "y");
+    KapaPrepPlot (kapa3, xHist->n, &graphdata);
+    KapaPlotVector (kapa3, xHist->n, xIndices->data.F32, "x");
+    KapaPlotVector (kapa3, xHist->n, xHist->data.F32, "y");
 
     // overplot the peak
@@ -1092,18 +1092,18 @@
     float y[2] = {-500, 500};
     graphdata.color = KapaColorByName ("red");
-    KapaPrepPlot (kapa1, 2, &graphdata);
-    KapaPlotVector (kapa1, 2, x, "x");
-    KapaPlotVector (kapa1, 2, y, "y");
+    KapaPrepPlot (kapa3, 2, &graphdata);
+    KapaPlotVector (kapa3, 2, x, "x");
+    KapaPlotVector (kapa3, 2, y, "y");
 
     // plot the Y histogram
     pmVisualScaleGraphdata(&graphdata, yIndices, yHist, false);
-    KapaSetSection(kapa1, &section2);
-    KapaSetLimits (kapa1, &graphdata);
-    KapaSetFont(kapa1, "helvetica", 14);
+    KapaSetSection(kapa3, &section2);
+    KapaSetLimits (kapa3, &graphdata);
+    KapaSetFont(kapa3, "helvetica", 14);
     graphdata.color = KapaColorByName ("black");
-    KapaBox(kapa1, &graphdata);
-    KapaSendLabel (kapa1, "Y offset Bin", KAPA_LABEL_XM);
-    KapaSendLabel (kapa1, "Number of Sources", KAPA_LABEL_YM);
-    KapaSendLabel (kapa1, "Vertical Profile",
+    KapaBox(kapa3, &graphdata);
+    KapaSendLabel (kapa3, "Y offset Bin", KAPA_LABEL_XM);
+    KapaSendLabel (kapa3, "Number of Sources", KAPA_LABEL_YM);
+    KapaSendLabel (kapa3, "Vertical Profile",
                    KAPA_LABEL_XP);
     graphdata.style = 1;
@@ -1111,20 +1111,20 @@
     graphdata.size = 0.4;
 
-    KapaPrepPlot (kapa1, yHist->n, &graphdata);
-    KapaPlotVector (kapa1, yHist->n, yIndices->data.F32, "x");
-    KapaPlotVector (kapa1, yHist->n, yHist->data.F32, "y");
+    KapaPrepPlot (kapa3, yHist->n, &graphdata);
+    KapaPlotVector (kapa3, yHist->n, yIndices->data.F32, "x");
+    KapaPlotVector (kapa3, yHist->n, yHist->data.F32, "y");
 
     // overplot the peak
     x[0] = x[1] = yBin;
     graphdata.color = KapaColorByName ("red");
-    KapaPrepPlot (kapa1, 2, &graphdata);
-    KapaPlotVector (kapa1, 2, x, "x");
-    KapaPlotVector (kapa1, 2, y, "y");
+    KapaPrepPlot (kapa3, 2, &graphdata);
+    KapaPlotVector (kapa3, 2, x, "x");
+    KapaPlotVector (kapa3, 2, y, "y");
 
     // plot title
     graphdata.color = KapaColorByName("black");
 
-    KapaSetSection( kapa1, &section3);
-    KapaSendLabel (kapa1, "Tweaking the Astrometry Grid Solution. Smoothed profiles + peak location",
+    KapaSetSection( kapa3, &section3);
+    KapaSendLabel (kapa3, "Tweaking the Astrometry Grid Solution. Smoothed profiles + peak location",
                    KAPA_LABEL_XP);
 
Index: trunk/psModules/src/astrom/pmAstrometryWCS.c
===================================================================
--- trunk/psModules/src/astrom/pmAstrometryWCS.c	(revision 40082)
+++ trunk/psModules/src/astrom/pmAstrometryWCS.c	(revision 40083)
@@ -695,5 +695,4 @@
     // the region defines the FPA pixels covered by the tranformation
     psFree (fpa->fromTPA);
-
     int additional_orders = 4;  // This is the number of orders that should be added.
     bool status = false;
@@ -704,4 +703,5 @@
     
     psPlaneTransform *myPT = psPlaneTransformAlloc(fpa->toTPA->x->nX+additional_orders, fpa->toTPA->x->nY+additional_orders);
+
     fpa->fromTPA = psPlaneTransformInvert(myPT, fpa->toTPA, region, 50);
     psFree (myPT);
