Index: factory/facFqFactorize.cc
===================================================================
--- factory/facFqFactorize.cc	(revision 5dad7c78535e5d3163be097e8a0d3e8d69c6593e)
+++ factory/facFqFactorize.cc	(revision c89740c263a7f55af9bd2cdbff4e77573d7eb82e)
@@ -2287,5 +2287,5 @@
   CFList biFactors, bufBiFactors;
   CanonicalForm evalPoly;
-  int lift, bufLift;
+  int lift, bufLift, lengthAeval2= A.level()-2;
   double logarithm= (double) ilog2 (totaldegree (A));
   logarithm /= log2exp;
@@ -2293,6 +2293,6 @@
   if (factorNums < (int) logarithm)
     factorNums= (int) logarithm;
-  CFList* bufAeval2= new CFList [A.level() - 2];
-  CFList* Aeval2= new CFList [A.level() - 2];
+  CFList* bufAeval2= new CFList [lengthAeval2];
+  CFList* Aeval2= new CFList [lengthAeval2];
   int counter;
   int differentSecondVar= 0;
@@ -2351,5 +2351,5 @@
     evaluationWRTDifferentSecondVars (bufAeval2, bufEvaluation, A);
 
-    for (int j= 0; j < A.level() - 2; j++)
+    for (int j= 0; j < lengthAeval2; j++)
     {
       if (!bufAeval2[j].isEmpty())
@@ -2392,5 +2392,5 @@
       biFactors= bufBiFactors;
       lift= bufLift;
-      for (int j= 0; j < A.level() - 2; j++)
+      for (int j= 0; j < lengthAeval2; j++)
         Aeval2 [j]= bufAeval2 [j];
       differentSecondVar= counter;
@@ -2406,5 +2406,5 @@
         biFactors= bufBiFactors;
         lift= bufLift;
-        for (int j= 0; j < A.level() - 2; j++)
+        for (int j= 0; j < lengthAeval2; j++)
           Aeval2 [j]= bufAeval2 [j];
         differentSecondVar= counter;
@@ -2446,5 +2446,5 @@
   minFactorsLength= tmin (minFactorsLength, biFactors.length());
 
-  if (differentSecondVar == A.level() - 2)
+  if (differentSecondVar == lengthAeval2)
   {
     bool zeroOccured= false;
@@ -2480,8 +2480,8 @@
   CFList uniFactors= buildUniFactors (biFactors, evaluation.getLast(), y);
 
-  sortByUniFactors (Aeval2, A.level() - 2, uniFactors, evaluation);
-
-  CFList * oldAeval= new CFList [A.level() - 2]; //TODO use bufAeval2 for this
-  for (int i= 0; i < A.level() - 2; i++)
+  sortByUniFactors (Aeval2, lengthAeval2, uniFactors, evaluation);
+
+  CFList * oldAeval= new CFList [lengthAeval2]; //TODO use bufAeval2 for this
+  for (int i= 0; i < lengthAeval2; i++)
     oldAeval[i]= Aeval2[i];
 
@@ -2494,5 +2494,5 @@
   Variable v;
   CFList leadingCoeffs= precomputeLeadingCoeff (LC (A, 1), biFactorsLCs, alpha,
-                                          evaluation, Aeval2, A.level() - 2, v);
+                                          evaluation, Aeval2, lengthAeval2, v);
 
   if (v.level() != 1)
@@ -2512,5 +2512,5 @@
       }
     }
-    for (i= 0; i < A.level() - 2; i++)
+    for (i= 0; i < lengthAeval2; i++)
     {
       if (oldAeval[i].isEmpty())
@@ -2560,8 +2560,10 @@
   }
 
+  CanonicalForm LCmultiplier= leadingCoeffs.getFirst();
+  bool LCmultiplierIsConst= LCmultiplier.inCoeffDomain();
   leadingCoeffs.removeFirst();
 
   //prepare leading coefficients
-  CFList* leadingCoeffs2= new CFList [A.level() - 2];
+  CFList* leadingCoeffs2= new CFList [lengthAeval2];
   prepareLeadingCoeffs (leadingCoeffs2, A.level(), leadingCoeffs, biFactors,
                         evaluation);
@@ -2574,6 +2576,22 @@
   A /= hh;
 
+  CFListIterator iter2;
+  CFList bufLeadingCoeffs2= leadingCoeffs2[lengthAeval2-1];
+  bufBiFactors= biFactors;
+  bufA= A;
+  CanonicalForm bufLCmultiplier= LCmultiplier;
+  CanonicalForm testVars;
+  if (!LCmultiplierIsConst)
+  {
+    testVars= Variable (2);
+    for (int i= 0; i < lengthAeval2; i++)
+    {
+      if (!oldAeval[i].isEmpty())
+        testVars *= oldAeval[i].getFirst().mvar();
+    }
+  }
   CFList bufFactors= CFList();
-  if (LucksWangSparseHeuristic (A, biFactors, 2, leadingCoeffs2 [A.level() - 3],
+  bool LCheuristic= false;
+  if (LucksWangSparseHeuristic (A, biFactors, 2, leadingCoeffs2 [lengthAeval2-1],
                                  factors))
   {
@@ -2586,5 +2604,5 @@
     {
       if (extension)
-        factors= extNonMonicFactorRecombination (factors, A, info);
+        factors= extNonMonicFactorRecombination (factors, bufA, info);       //TODO brauche hier ein bufA statt A
 
       if (v.level() != 1)
@@ -2613,5 +2631,5 @@
             iter++;
           iter.remove (1);
-          for (int j= 0; j < A.level() -2; j++)
+          for (int j= 0; j < lengthAeval2; j++)
           {
             l= leadingCoeffs2[j];
@@ -2638,12 +2656,12 @@
     iter.getItem()= iter.getItem () (y + evaluation.getLast(), y);
 
-  for (int i= 0; i < A.level() - 3; i++)
+  for (int i= 0; i < lengthAeval2-1; i++)
     leadingCoeffs2[i]= CFList();
-  for (iter= leadingCoeffs2[A.level() - 3]; iter.hasItem(); iter++)
+  for (iter= leadingCoeffs2[lengthAeval2-1]; iter.hasItem(); iter++)
   {
     iter.getItem()= shift2Zero (iter.getItem(), list, evaluation);
     for (int i= A.level() - 4; i > -1; i--)
     {
-      if (i + 1 == A.level() - 3)
+      if (i + 1 == lengthAeval2-1)
         leadingCoeffs2[i].append (iter.getItem() (0, i + 4));
       else
