Index: Singular/dyn_modules/gfanlib/tropicalStrategy.cc
===================================================================
--- Singular/dyn_modules/gfanlib/tropicalStrategy.cc	(revision b71400abefd0c9c66c0009063f40ddd5b1f1c4c7)
+++ Singular/dyn_modules/gfanlib/tropicalStrategy.cc	(revision dffd1541cc74564f509bd5d284948852484430b0)
@@ -9,4 +9,5 @@
 #include <kernel/ideals.h>
 #include <kernel/GBEngine/stairc.h>
+#include <kernel/GBEngine/kstd1.h>
 #include <Singular/ipshell.h> // for isPrime(int i)
 
@@ -48,5 +49,4 @@
  * Initializes all relevant structures and information for the trivial valuation case,
  * i.e. computing a tropical variety without any valuation.
- *g
  */
 tropicalStrategy::tropicalStrategy(const ideal I, const ring r,
@@ -67,5 +67,4 @@
 {
   assume(rField_is_Q(r) || rField_is_Zp(r));
-  startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
   if (!completelyHomogeneous)
   {
@@ -127,4 +126,42 @@
   }
   return rCopy(r);
+}
+
+static ideal constructStartingIdeal(ideal originalIdeal, ring originalRing, number uniformizingParameter, ring startingRing)
+{
+  // construct p-t
+  poly g = p_One(startingRing);
+  p_SetCoeff(g,uniformizingParameter,startingRing);
+  pNext(g) = p_One(startingRing);
+  p_SetExp(pNext(g),1,1,startingRing);
+  p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing);
+  p_Setm(pNext(g),startingRing);
+  ideal pt = idInit(1);
+  pt->m[0] = g;
+
+  // map originalIdeal from originalRing into startingRing
+  int k = idSize(originalIdeal);
+  ideal J = idInit(k+1);
+  nMapFunc nMap = n_SetMap(originalRing->cf,startingRing->cf);
+  int n = rVar(originalRing);
+  int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int));
+  for (int i=1; i<=n; i++)
+    shiftByOne[i]=i+1;
+  for (int i=0; i<k; i++)
+    J->m[i] = p_PermPoly(originalIdeal->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0);
+  omFreeSize(shiftByOne,(n+1)*sizeof(int));
+
+  ring origin = currRing;
+  rChangeCurrRing(startingRing);
+  ideal startingIdeal = kNF(pt,startingRing->qideal,J);
+  rChangeCurrRing(origin);
+  assume(startingIdeal->m[k]==NULL);
+  startingIdeal->m[k] = pt->m[0];
+  startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
+
+  id_Delete(&J,startingRing);
+  pt->m[0] = NULL;
+  id_Delete(&pt,startingRing);
+  return startingIdeal;
 }
 
@@ -149,5 +186,4 @@
   /* assume that the ground field of the originalRing is Q */
   assume(rField_is_Q(s));
-  originalRing = rCopy(s);
 
   /* replace Q with Z for the startingRing
@@ -160,21 +196,5 @@
 
   /* map the input ideal into the new polynomial ring */
-  int k = idSize(J);
-  startingIdeal = idInit(k+1);
-  poly g = p_One(startingRing);
-  p_SetCoeff(g,uniformizingParameter,startingRing);
-  pNext(g) = p_One(startingRing);
-  p_SetExp(pNext(g),1,1,startingRing);
-  p_SetCoeff(pNext(g),n_Init(-1,startingRing->cf),startingRing);
-  p_Setm(pNext(g),startingRing);
-  startingIdeal->m[0] = g;
-  int n = rVar(originalRing);
-  int* shiftByOne = (int*) omAlloc((n+1)*sizeof(int));
-  for (int i=1; i<=n; i++)
-    shiftByOne[i]=i+1;
-  for (int i=0; i<k; i++)
-    startingIdeal->m[i+1] = p_PermPoly(J->m[i],shiftByOne,originalRing,startingRing,nMap,NULL,0);
-  omFreeSize(shiftByOne,(n+1)*sizeof(int));
-  startingIdeal = gfanlib_kStd_wrapper(startingIdeal,startingRing);
+  startingIdeal = constructStartingIdeal(J,s,uniformizingParameter,startingRing);
 
   linealitySpace = homogeneitySpace(startingIdeal,startingRing);
@@ -529,4 +549,20 @@
 }
 
+ideal tropicalStrategy::computeLift(const ideal inJs, const ring s, const ideal inIr, const ideal Ir, const ring r) const
+{
+  int k = idSize(inJs);
+  ideal inJr = idInit(k);
+  nMapFunc identitysr = n_SetMap(s->cf,r->cf);
+  for (int i=0; i<k; i++)
+    inJr->m[i] = p_PermPoly(inJs->m[i],NULL,s,r,identitysr,NULL,0);
+
+  ideal Jr = getWitness(inJr,inIr,Ir,r);
+  nMapFunc identityrs = n_SetMap(r->cf,s->cf);
+  ideal Js = idInit(k);
+  for (int i=0; i<k; i++)
+    Js->m[i] = p_PermPoly(Jr->m[i],NULL,r,s,identityrs,NULL,0);
+  return Js;
+}
+
 static void deleteOrdering(ring r)
 {
@@ -610,18 +646,17 @@
 }
 
-
-std::pair<ideal,ring> tropicalStrategy::getFlip(const ideal I, const ideal redI, const ring r,
+std::pair<ideal,ring> tropicalStrategy::getFlip(const ideal Ir, const ring r,
                                                 const gfan::ZVector interiorPoint,
                                                 const gfan::ZVector facetNormal) const
 {
   assume(isValuationTrivial() || interiorPoint[0].sign()<0);
-  assume(checkForUniformizingBinomial(I,r));
+  assume(checkForUniformizingBinomial(Ir,r));
 
   // get a generating system of the initial ideal
   // and compute a standard basis with respect to adjacent ordering
-  ideal inIr = initial(redI,r,interiorPoint);
+  ideal inIr = initial(Ir,r,interiorPoint);
   ring sAdjusted = copyAndChangeOrderingWP(r,interiorPoint,facetNormal);
   nMapFunc identity = n_SetMap(r->cf,sAdjusted->cf);
-  int k = idSize(I); ideal inIsAdjusted = idInit(k);
+  int k = idSize(Ir); ideal inIsAdjusted = idInit(k);
   for (int i=0; i<k; i++)
     inIsAdjusted->m[i] = p_PermPoly(inIr->m[i],NULL,r,sAdjusted,identity,NULL,0);
@@ -636,5 +671,5 @@
     inJr->m[i] = p_PermPoly(inJsAdjusted->m[i],NULL,sAdjusted,r,identity,NULL,0);
 
-  ideal Jr = getWitness(inJr,inIr,redI,r);
+  ideal Jr = getWitness(inJr,inIr,Ir,r);
   ring s = copyAndChangeOrderingLS(r,interiorPoint,facetNormal);
   identity = n_SetMap(r->cf,s->cf);
