Index: /branches/czw_branch/20160809/psastro/src/psastroMosaicAstrom.c
===================================================================
--- /branches/czw_branch/20160809/psastro/src/psastroMosaicAstrom.c	(revision 39723)
+++ /branches/czw_branch/20160809/psastro/src/psastroMosaicAstrom.c	(revision 39724)
@@ -280,5 +280,9 @@
 
     // psPlaneTransformInvert will generate a new fromTPA with order to match toTPA
-    fpa->fromTPA = psPlaneTransformInvert (fpa->fromTPA, fpa->toTPA, fitRegion, 100);
+    psFree (fpa->fromTPA);
+    psPlaneTransform *myPT = psPlaneTransformAlloc(fpa->toTPA->x->nX+4, fpa->toTPA->x->nY+4);
+
+    fpa->fromTPA = psPlaneTransformInvert (myPT, fpa->toTPA, fitRegion, 100);
+    psFree (myPT);
 
     psFree (fpa->toSky);
@@ -291,4 +295,10 @@
 
     psFree (view);
+
+    if (!psastroMosaicSetAstrom (fpa)) {
+	psError(PSASTRO_ERR_UNKNOWN, false, "failed to apply mosaic distortion terms\n");
+        return false;
+    }
+
     return true;
 }
Index: /branches/czw_branch/20160809/psastro/src/psastroMosaicCorrectDistortion.c
===================================================================
--- /branches/czw_branch/20160809/psastro/src/psastroMosaicCorrectDistortion.c	(revision 39723)
+++ /branches/czw_branch/20160809/psastro/src/psastroMosaicCorrectDistortion.c	(revision 39724)
@@ -62,5 +62,7 @@
 
     psFree (fpa->fromTPA);
-    fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, *region, 50);
+    psPlaneTransform *myPT = psPlaneTransformAlloc(fpa->toTPA->x->nX+4, fpa->toTPA->x->nY+4);
+    fpa->fromTPA = psPlaneTransformInvert(myPT, fpa->toTPA, *region, 50);
+    psFree (myPT);
     psFree (region);
 
