Index: /trunk/pswarp/src/pswarpLoadAstrometry.c
===================================================================
--- /trunk/pswarp/src/pswarpLoadAstrometry.c	(revision 41896)
+++ /trunk/pswarp/src/pswarpLoadAstrometry.c	(revision 41897)
@@ -94,16 +94,7 @@
         }
     }
+
     // apply the bilevel astrometry elements to the target
     if (bilevelAstrometry) {
-      int additional_orders = 4;
-      bool status = false;
-      int config_additional_orders = psMetadataLookupS32(&status,config->arguments,"ADDITIONAL_WCS_ORDERS");
-      if (status) {
-	additional_orders = config_additional_orders;
-      }
-      psMetadataAddS32(astrom->fpa->analysis,PS_LIST_TAIL, "ADDITIONAL_WCS_ORDERS", PS_META_REPLACE,
-		       "Additional orders for bilevel fit.", additional_orders);
-      
-	
 	if (!pmAstromReadBilevelMosaic(astrom->fpa, phu->header)) {
 	    psError(psErrorCodeLast(), false, "Unable to read bilevel mosaic astrometry for skycell.");
Index: /trunk/pswarp/src/pswarpLoop.c
===================================================================
--- /trunk/pswarp/src/pswarpLoop.c	(revision 41896)
+++ /trunk/pswarp/src/pswarpLoop.c	(revision 41897)
@@ -240,5 +240,5 @@
 
     // use a map with only linear terms in x,y
-    psPlaneTransform *map = psPlaneTransformAlloc(1,1);
+    psPlaneTransform *map = psPlaneTransformAlloc(1, 1, PS_POLYNOMIAL_ORD);
     map->x->coeffMask[1][1] = PS_POLY_MASK_BOTH;
     map->y->coeffMask[1][1] = PS_POLY_MASK_BOTH;
Index: /trunk/pswarp/src/pswarpMapGrid.c
===================================================================
--- /trunk/pswarp/src/pswarpMapGrid.c	(revision 41896)
+++ /trunk/pswarp/src/pswarpMapGrid.c	(revision 41897)
@@ -44,4 +44,5 @@
     for (ni = 0, i = xMin; ni < nXpts; i += nXpix, ni++) {
         for (nj = 0, j = yMin; nj < nYpts; j += nYpix, nj++) {
+//	  pswarpMapSetLocalModel (grid->maps[ni][nj], dest, src, i, j, nXpix, nYpix);
             pswarpMapSetLocalModel (grid->maps[ni][nj], dest, src, i, j);
         }
@@ -196,4 +197,5 @@
  * astrometric transformations are supplied for the parent image coordinate frame.
  */
+// bool pswarpMapSetLocalModel (pswarpMap *map, pmReadout *dest, pmReadout *src, int ix, int iy, int dX, int dY) {
 bool pswarpMapSetLocalModel (pswarpMap *map, pmReadout *dest, pmReadout *src, int ix, int iy) {
 
@@ -234,4 +236,5 @@
 
     /** V(1,0) position */
+//  offset->x = ix + dX;
     offset->x = ix + 1;
     offset->y = iy;
@@ -246,4 +249,5 @@
     offset->x = ix;
     offset->y = iy + 1;
+//  offset->y = iy + dY;
     psPlaneTransformApply(FP, chipSrc->toFPA, offset);
     psPlaneTransformApply (TP, fpaSrc->toTPA, FP);
Index: /trunk/pswarp/src/pswarpOptions.c
===================================================================
--- /trunk/pswarp/src/pswarpOptions.c	(revision 41896)
+++ /trunk/pswarp/src/pswarpOptions.c	(revision 41897)
@@ -104,6 +104,6 @@
       config_additional_orders = 0;
     }
-    
-
+    pmAstrometrySetExtraOrders(config_additional_orders);
+    // This is the number of orders that should be added to all non-linear inverse transformations
     
     // Set recipe values in the recipe (since we've possibly altered some)
