Index: factory/facFqBivar.cc
===================================================================
--- factory/facFqBivar.cc	(revision 1a3011e587832b2682cb4978c6d117754eaa2572)
+++ factory/facFqBivar.cc	(revision 69c8820d335e5e0a8ddcbf89ce82547457c3ec66)
@@ -651,4 +651,5 @@
         LCBuf= LC (buf, x);
         T= Difference (T, CFList (i.getItem()));
+        F= buf;
 
         // compute new possible degree pattern
@@ -667,8 +668,6 @@
   if (adaptedLiftBound < deg)
   {
+    degs= bufDegs1;
     success= true;
-    factors= T;
-    degs= bufDegs1;
-    F= buf;
   }
   if (bufDegs1.getLength() <= 1)
@@ -743,4 +742,5 @@
         {
           T= Difference (T, CFList (i.getItem()));
+          F= buf;
 
           // compute new possible degree pattern
@@ -763,8 +763,6 @@
   if (adaptedLiftBound < deg)
   {
+    degs= bufDegs1;
     success= true;
-    factors= T;
-    degs= bufDegs1;
-    F= buf;
   }
   if (bufDegs1.getLength() <= 1)
@@ -828,31 +826,16 @@
 
 void
-deleteFactors (const CFList& L, CFList& factors, const CanonicalForm& eval, bool
-               extension)
+deleteFactors (CFList& factors, int* factorsFoundIndex)
 {
-  int index;
-  CanonicalForm tmp1, tmp2;
-  CFListIterator j;
-  Variable y= Variable (2);
-  for (CFListIterator i= L; i.hasItem(); i++)
-  {
-    index= 1;
-    if (extension)
-      tmp1= mod (i.getItem(), y-eval);
+  CFList result;
+  int i= 0;
+  for (CFListIterator iter= factors; iter.hasItem(); iter++, i++)
+  {
+    if (factorsFoundIndex[i] == 1)
+      continue;
     else
-      tmp1= mod (i.getItem(), y);
-    tmp1 /= Lc (tmp1);
-    for (j= factors; j.hasItem(); j++, index++)
-    {
-      tmp2= mod (j.getItem(), y);
-      tmp2 /= Lc (tmp2);
-      if (tmp1 == tmp2)
-      {
-        index++;
-        j.remove(index);
-        break;
-      }
-    }
-  }
+      result.append (iter.getItem());
+  }
+  factors= result;
 }
 
@@ -887,4 +870,5 @@
   for (int i= 0; i < uniFactors.length(); i++)
     factorsFoundIndex [i]= 0;
+  CanonicalForm bufA= A;
 
   if (smallFactorDeg >= liftBound || degree (A,y) <= 4)
@@ -894,9 +878,9 @@
     henselLift12 (A, bufUniFactors, smallFactorDeg, Pi, diophant, M);
     if (!extension)
-      earlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+      earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                             factorsFoundIndex, degs, earlySuccess,
                             smallFactorDeg);
     else
-      extEarlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+      extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                factorsFoundIndex, degs, earlySuccess, info,
                                eval, smallFactorDeg);
@@ -910,9 +894,9 @@
                             liftPre[sizeOfLiftPre-1] + 1, Pi, diophant, M);
         if (!extension)
-          earlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+          earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                 factorsFoundIndex, degs, earlySuccess,
                                 liftPre[sizeOfLiftPre-1] + 1);
         else
-          extEarlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+          extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                    factorsFoundIndex, degs, earlySuccess, info,
                                    eval, liftPre[sizeOfLiftPre-1] + 1);
@@ -931,9 +915,9 @@
                             liftPre[i-1] + 1, Pi, diophant, M);
         if (!extension)
-          earlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+          earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                 factorsFoundIndex, degs, earlySuccess,
                                 liftPre[i-1] + 1);
         else
-          extEarlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+          extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                    factorsFoundIndex, degs, earlySuccess, info,
                                    eval, liftPre[i-1] + 1);
@@ -954,9 +938,9 @@
     henselLift12 (A, bufUniFactors, smallFactorDeg, Pi, diophant, M);
     if (!extension)
-      earlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+      earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                             factorsFoundIndex, degs, earlySuccess,
                             smallFactorDeg);
     else
-      extEarlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+      extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                factorsFoundIndex, degs, earlySuccess, info,
                                eval, smallFactorDeg);
@@ -971,8 +955,8 @@
                           dummy, Pi, diophant, M);
       if (!extension)
-        earlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+        earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                               factorsFoundIndex, degs, earlySuccess, dummy);
       else
-        extEarlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+        extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                  factorsFoundIndex, degs, earlySuccess, info,
                                  eval, dummy);
@@ -987,8 +971,8 @@
                             dummy, Pi, diophant, M);
         if (!extension)
-          earlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+          earlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                 factorsFoundIndex, degs, earlySuccess, dummy);
         else
-          extEarlyFactorDetection (earlyFactors, A, bufUniFactors, newLiftBound,
+          extEarlyFactorDetection (earlyFactors, bufA, bufUniFactors, newLiftBound,
                                    factorsFoundIndex, degs, earlySuccess, info,
                                    eval, dummy);
@@ -1003,4 +987,12 @@
     if (earlySuccess)
       liftBound= newLiftBound;
+  }
+
+  A= bufA;
+  if (earlyFactors.length() > 0 && degs.getLength() > 1)
+  {
+    liftBound= degree (A,y) + 1;
+    earlySuccess= true;
+    deleteFactors (bufUniFactors, factorsFoundIndex);
   }
 
@@ -4253,16 +4245,8 @@
     return earlyFactors;
   }
-  int sizeOldF= size (F);
-  CFList result;
-  CanonicalForm bufF= F;
-  if (earlyFactors.length() > 0)
-  {
-    for (CFListIterator i= earlyFactors; i.hasItem(); i++)
-      bufF /= i.getItem();
-  }
-
-  if (size (bufF) < sizeOldF)
-  {
-    H= bufF;
+  int sizeOldF= size (G);
+  if (size (F) < sizeOldF)
+  {
+    H= F;
     success= true;
     return earlyFactors;
@@ -4309,22 +4293,11 @@
   }
   Variable y= F.mvar();
-  CanonicalForm shiftedF= F (y - evaluation, y);
+  CanonicalForm shiftedF= G (y - evaluation, y);
   int sizeOldF= size (shiftedF);
-  CFList result;
-  CanonicalForm bufF= shiftedF;
-  if (earlyFactors.length() > 0)
-  {
-    for (CFListIterator i= earlyFactors; i.hasItem(); i++)
-    {
-      bufF /= i.getItem();
-      result.append (i.getItem());
-    }
-  }
-
-  if (size (bufF) < sizeOldF)
-  {
-    H= bufF (y + evaluation, y); //shift back to zero
+  if (size (F) < sizeOldF)
+  {
+    H= F (y + evaluation, y); //shift back to zero
     success= true;
-    return result;
+    return earlyFactors;
   }
   else
