diff --git a/tracy/tracy/src/t2elem.cc b/tracy/tracy/src/t2elem.cc
index a28630b51593d85787c1a4be5b05ee71d34338a7..717cb84f9aead42214134181ef3feeacc3be5430 100644
--- a/tracy/tracy/src/t2elem.cc
+++ b/tracy/tracy/src/t2elem.cc
@@ -1046,8 +1046,8 @@ void Mpole_Pass(CellType &Cell, ss_vect<T> &x) {
 
     case Meth_Fourth:
         if (M->Pthick == thick) {
-            dL1 = c_1 * dL;
-            dL2 = c_2 * dL;
+            dL1  = c_1 * dL;
+            dL2  = c_2 * dL;
             dkL1 = d_1 * dL;
             dkL2 = d_2 * dL;
 
@@ -1749,11 +1749,11 @@ void Insertion_Pass(CellType &Cell, ss_vect<T> &x) {
             * elemp->ID->scaling2;
 
     //  /* Global -> Local */
-    //  GtoL(X, Cell->dS, Cell->dT, 0.0, 0.0, 0.0);
+     // GtoL(X, Cell->dS, Cell->dT, 0.0, 0.0, 0.0);
 
-    // (Nslice+1) drifts, n slice kicks
-    LN = elemp->PL / (Nslice + 1);
-    Drift(LN, x);
+    // Nslice*2*1/2  drifts, Nslice kicks
+    LN = elemp->PL / Nslice;
+    Drift(LN/2.0, x);
 
     for (i = 1; i <= Nslice; i++) {
         // First order kick map
@@ -1767,7 +1767,7 @@ void Insertion_Pass(CellType &Cell, ss_vect<T> &x) {
                         1);
             }
             if (outoftable) {
-                x[x_] = 1e30;
+                x[x_] = NAN;
                 return;
             }
 
@@ -1788,7 +1788,7 @@ void Insertion_Pass(CellType &Cell, ss_vect<T> &x) {
                         2);
             }
             if (outoftable) {
-                x[x_] = 1e30;
+                x[x_] = NAN;
                 return;
             }
 
@@ -1796,12 +1796,16 @@ void Insertion_Pass(CellType &Cell, ss_vect<T> &x) {
             x[px_] += d * tx2;
             x[py_] += d * tz2;
         }
-        Drift(LN, x);
+	if (i != Nslice)
+          Drift(LN, x);
+        else
+          Drift(LN/2.0, x);
+
     }
-    //  CopyVec(6L, x, Cell->BeamPos);
+      //CopyVec(6L, x, Cell->BeamPos);
 
-    //  /* Local -> Global */
-    //  LtoG(X, Cell->dS, Cell->dT, 0.0, 0.0, 0.0);
+      /* Local -> Global */
+      //LtoG(X, Cell->dS, Cell->dT, 0.0, 0.0, 0.0);
 }
 
 template<typename T>
@@ -2663,6 +2667,7 @@ void Insertion_SetMatrix(int Fnum1, int Knum1) {
     double DTHXDX = 0.0, DTHXDZ = 0.0, DTHZDX = 0.0, DTHZDZ = 0.0;
     int Nslice = 0;
 
+    fprintf(stdout, "inside Insertion_SetMatrix\n");
     if (ElemFam[Fnum1 - 1].nKid <= 0)
         return;
 
@@ -2680,11 +2685,11 @@ void Insertion_SetMatrix(int Fnum1, int Knum1) {
 
     //  if (globval.radiation == false && globval.Cavity_on == false)
     //  {
-    /* (Nslice + 1) Drifts for Nslice Kicks */
+    /* Nslice Drifts for Nslice Kicks */
 
     /* Drift Matrix */
-    L = elemp->PL / (Nslice + 1) / (1.0 + globval.dPparticle);
-    make4by5(ID->D55, 1.0, L, 0.0, 0.0, 1.0, 0.0, 1.0, L, 0.0, 0.0, 1.0, 0.0);
+    L = elemp->PL / Nslice  / (1.0 + globval.dPparticle);
+    make4by5(ID->D55, 1.0, L/2.0, 0.0, 0.0, 1.0, 0.0, 1.0, L/2.0, 0.0, 0.0, 1.0, 0.0);
 
     /* First order Kick */
     if (ID->firstorder) {