Index: factory/canonicalform.cc
===================================================================
--- factory/canonicalform.cc	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/canonicalform.cc	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -15,8 +15,10 @@
 #include "cf_algorithm.h"
 #include "imm.h"
+#include "int_pp.h"
 #include "gfops.h"
 #include "facMul.h"
 #include "facAlgFuncUtil.h"
 #include "FLINTconvert.h"
+#include "cf_binom.h"
 
 #ifndef NOSTREAMIO
@@ -204,4 +206,5 @@
 }
 
+
 CanonicalForm
 CanonicalForm::mapinto () const
@@ -216,4 +219,6 @@
             else
                 return *this;
+        else  if ( CFFactory::gettype() == PrimePowerDomain )
+            return CanonicalForm( CFFactory::basic( imm2int( value ) ) );
         else  if ( getGFDegree() == 1 )
             return CanonicalForm( int2imm_p( ff_norm( imm2int( value ) ) ) );
@@ -222,5 +227,28 @@
     else  if ( value->inBaseDomain() )
         if ( getCharacteristic() == 0 )
-             return *this;
+            if ( value->levelcoeff() == PrimePowerDomain )
+            {
+              mpz_t d;
+              getmpi( value,d);
+              if ( mpz_cmp( InternalPrimePower::primepowhalf, d ) < 0 )
+                mpz_sub( d, d, InternalPrimePower::primepow );
+              return CFFactory::basic( d );
+            }
+            else
+                return *this;
+        else  if ( CFFactory::gettype() == PrimePowerDomain )
+        {
+            ASSERT( value->levelcoeff() == PrimePowerDomain || value->levelcoeff() == IntegerDomain, "no proper map defined" );
+            if ( value->levelcoeff() == PrimePowerDomain )
+                return *this;
+            else
+            {
+              mpz_t d;
+              getmpi(value,d);
+              if ( mpz_cmp( InternalPrimePower::primepowhalf, d ) < 0 )
+                mpz_sub( d, d, InternalPrimePower::primepow );
+              return CFFactory::basic( d );
+            }
+        }
         else
         {
@@ -248,5 +276,4 @@
     }
 }
-
 /** CanonicalForm CanonicalForm::lc (), Lc (), LC (), LC ( v ) const
  *
@@ -1935,2 +1962,16 @@
     return cf_glob_switches.isOn( sw );
 }
+
+#ifndef HAVE_NTL
+static int initialized=0;
+int
+initCanonicalForm( void )
+{
+  if ( ! initialized )
+  {
+    initPT();
+    initialized = true;
+  }
+}
+#endif
+
Index: factory/canonicalform.h
===================================================================
--- factory/canonicalform.h	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/canonicalform.h	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -404,3 +404,5 @@
 /*ENDPUBLIC*/
 
+int initCanonicalForm( void );
+static int cf_is_initialized_now = initCanonicalForm();
 #endif /* ! INCL_CANONICALFORM_H */
Index: factory/cf_binom.h
===================================================================
--- factory/cf_binom.h	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/cf_binom.h	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -1,8 +1,9 @@
 /* emacs edit mode for this file is -*- C++ -*- */
+/* $Id: cf_binom.h 12231 2009-11-02 10:12:22Z hannes $ */
 
 #ifndef INCL_CF_BINOM_H
 #define INCL_CF_BINOM_H
 
-// #include "config.h"
+#include <config.h>
 
 #include "canonicalform.h"
Index: factory/cf_factory.cc
===================================================================
--- factory/cf_factory.cc	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/cf_factory.cc	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -14,4 +14,5 @@
 #include "int_rat.h"
 #include "int_poly.h"
+#include "int_pp.h"
 #include "imm.h"
 
@@ -46,4 +47,6 @@
     case GaloisFieldDomain:
         return int2imm_gf( gf_int2gf( value ) );
+    case PrimePowerDomain:
+        return new InternalPrimePower( value );
     default: {
         ASSERT( 0, "illegal basic domain!" );
@@ -260,6 +263,5 @@
 void getmpi ( InternalCF * value, mpz_t mpi)
 {
-    ASSERT( ! is_imm( value ) && (value->levelcoeff() == IntegerDomain ), "illegal operation" );
+    ASSERT( ! is_imm( value ) && (value->levelcoeff() == IntegerDomain || value->levelcoeff() == PrimePowerDomain), "illegal operation" );
     mpz_init_set (mpi, ((InternalInteger*)value)->thempi);
 }
-
Index: factory/cf_factory.h
===================================================================
--- factory/cf_factory.h	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/cf_factory.h	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -29,5 +29,5 @@
     static void settype ( int type )
     {
-      ASSERT( type==FiniteFieldDomain || type==GaloisFieldDomain || type==IntegerDomain || type==RationalDomain, "illegal basic domain!" );
+      ASSERT( type==FiniteFieldDomain || type==GaloisFieldDomain || type==IntegerDomain || type==RationalDomain || type==PrimePowerDomain, "illegal basic domain!" );
       currenttype = type;
     };
@@ -46,4 +46,3 @@
 
 void getmpi ( InternalCF * value, mpz_t mpi);
-
 #endif /* ! INCL_CF_FACTORY_H */
Index: factory/fac_distrib.cc
===================================================================
--- factory/fac_distrib.cc	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/fac_distrib.cc	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -1,9 +1,8 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-
-
-#include "config.h"
-
-
-#include "cf_assert.h"
+/* $Id: fac_distrib.cc 14344 2011-07-25 14:08:17Z mlee $ */
+
+#include <config.h>
+
+#include "assert.h"
 #include "debug.h"
 
@@ -16,4 +15,5 @@
 
 #ifndef HAVE_NTL
+
 bool
 nonDivisors ( CanonicalForm omega, CanonicalForm delta, const CFArray & F, CFArray & d )
Index: factory/fac_distrib.h
===================================================================
--- factory/fac_distrib.h	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/fac_distrib.h	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -1,8 +1,9 @@
 /* emacs edit mode for this file is -*- C++ -*- */
+/* $Id: fac_distrib.h 12231 2009-11-02 10:12:22Z hannes $ */
 
 #ifndef INCL_FAC_DISTRIB_H
 #define INCL_FAC_DISTRIB_H
 
-// #include "config.h"
+#include <config.h>
 
 #include "canonicalform.h"
Index: factory/fac_multihensel.cc
===================================================================
--- factory/fac_multihensel.cc	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/fac_multihensel.cc	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -1,9 +1,8 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-
-
-#include "config.h"
-
-
-#include "cf_assert.h"
+/* $Id: fac_multihensel.cc 12231 2009-11-02 10:12:22Z hannes $ */
+
+#include <config.h>
+
+#include "assert.h"
 #include "debug.h"
 #include "timing.h"
@@ -14,16 +13,15 @@
 #include "fac_util.h"
 #include "fac_iterfor.h"
-#include "fac_multihensel.h"
 #include "cf_iter.h"
 
 #ifndef HAVE_NTL
 
-TIMING_DEFINE_PRINT(fac_solve)
-TIMING_DEFINE_PRINT(fac_modpk)
-TIMING_DEFINE_PRINT(fac_corrcoeff)
-TIMING_DEFINE_PRINT(fac_extgcd)
+TIMING_DEFINE_PRINT(fac_solve);
+TIMING_DEFINE_PRINT(fac_modpk);
+TIMING_DEFINE_PRINT(fac_corrcoeff);
+TIMING_DEFINE_PRINT(fac_extgcd);
 
 static void
-extgcdrest ( const CanonicalForm & a, const CanonicalForm & b, const CanonicalForm & s, const CanonicalForm & t, const CanonicalForm & c, CanonicalForm & S, CanonicalForm & T, const modpk & /*pk*/ )
+extgcdrest ( const CanonicalForm & a, const CanonicalForm & b, const CanonicalForm & s, const CanonicalForm & t, const CanonicalForm & c, CanonicalForm & S, CanonicalForm & T, const modpk & pk )
 {
     CanonicalForm sigma = s * c, tau = t * c;
@@ -169,5 +167,5 @@
         A[i] = remainder( pk( a[i] * C0 ), P0[i], pk );
     DEBOUTLN( cerr, "the first approximation of the correction coefficients is " << A );
-/*#ifdef DEBUGOUTPUT
+#ifdef DEBUGOUTPUT
     if ( check_dummy( A, P, Q ) - C != 0 )
     {
@@ -177,5 +175,5 @@
         DEBOUTLN( cerr, "              Q " << Q );
     }
-#endif*/
+#endif
     for ( m = 0; m <= h && ( m == 0 || Dm != 0 ); m++ )
     {
@@ -219,5 +217,5 @@
         DEBOUTLN( cerr, "the correction coefficients at step " << m );
         DEBOUTLN( cerr, "are now " << A );
-/*#ifdef DEBUGOUTPUT
+#ifdef DEBUGOUTPUT
     if ( check_dummy( A, P, Q ) - C != 0 ) {
         DEBOUTLN( cerr, "there is an error detected, the correction coefficients do not" );
@@ -226,5 +224,5 @@
         DEBOUTLN( cerr, "              Q " << Q );
     }
-#endif*/
+#endif
     }
     DEBDECLEVEL( cerr, "findCorrCoeffs" );
@@ -326,5 +324,5 @@
 
 bool
-Hensel ( const CanonicalForm & U, CFArray & G, const CFArray & lcG, const Evaluation & A, const modpk & bound, const Variable & /*x*/ )
+Hensel ( const CanonicalForm & U, CFArray & G, const CFArray & lcG, const Evaluation & A, const modpk & bound, const Variable & x )
 {
     DEBINCLEVEL( cerr, "Hensel" );
Index: factory/fac_multivar.cc
===================================================================
--- factory/fac_multivar.cc	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/fac_multivar.cc	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -1,9 +1,8 @@
 /* emacs edit mode for this file is -*- C++ -*- */
-
-
-#include "config.h"
-
-
-#include "cf_assert.h"
+/* $Id: fac_multivar.cc 14377 2011-09-01 13:40:30Z mlee $ */
+
+#include <config.h>
+
+#include "assert.h"
 #include "debug.h"
 #include "timing.h"
@@ -21,13 +20,15 @@
 #include "fac_distrib.h"
 #include "fac_multihensel.h"
+#include "facBivar.h"
 
 #ifndef HAVE_NTL
+
 void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
 void out_cff(CFFList &L);
 
-TIMING_DEFINE_PRINT(fac_content)
-TIMING_DEFINE_PRINT(fac_findeval)
-TIMING_DEFINE_PRINT(fac_distrib)
-TIMING_DEFINE_PRINT(fac_hensel)
+TIMING_DEFINE_PRINT(fac_content);
+TIMING_DEFINE_PRINT(fac_findeval);
+TIMING_DEFINE_PRINT(fac_distrib);
+TIMING_DEFINE_PRINT(fac_hensel);
 
 static CFArray
@@ -69,5 +70,5 @@
 
 static modpk
-coeffBound ( const CanonicalForm & f, int p )
+coeffBound_old ( const CanonicalForm & f, int p )
 {
     int * degs = degrees( f );
@@ -148,6 +149,6 @@
 }
 
-#ifdef HAVE_NTL
-VAR int prime_number=0;
+
+static int prime_number=0;
 void find_good_prime(const CanonicalForm &f, int &start)
 {
@@ -199,8 +200,9 @@
   }
 }
-#endif
-
 static CFArray ZFactorizeMulti ( const CanonicalForm & arg )
 {
+    prime_number=0;
+    bool is_rat=isOn(SW_RATIONAL);
+    Off(SW_RATIONAL);
     DEBINCLEVEL( cerr, "ZFactorizeMulti" );
     CFMap M;
@@ -264,5 +266,4 @@
         G = conv_to_factor_array( factorize( U0, false ) );
         DEBOUTLN( cerr, "which factorizes into " << G );
-        #ifdef HAVE_NTL
         {
           int i=prime_number;
@@ -279,18 +280,15 @@
           else if (((i==0)||(i!=prime_number)))
           {
-            b = coeffBound( U, p );
+            b = coeffBound_old( U, p );
             prime_number=i;
           }
           // p!=0:
-          modpk bb=coeffBound(U0,p);
+          modpk bb=coeffBound_old(U0,p);
           if (bb.getk() > b.getk() ) b=bb;
-          bb=coeffBound(arg,p);
+          bb=coeffBound_old(arg,p);
           if (bb.getk() > b.getk() ) b=bb;
         }
-        #else
-        b = coeffBound( U, getZFacModulus().getp() );
         if ( getZFacModulus().getpk() > b.getpk() )
             b = getZFacModulus();
-        #endif
         //printf("p=%d, k=%d\n",b.getp(),b.getk());
         DEBOUTLN( cerr, "the coefficient bound of the factors of U is " << b.getpk() );
@@ -342,4 +340,5 @@
         G[1] = -G[1];
     DEBDECLEVEL( cerr, "ZFactorMulti" );
+    if(is_rat) On(SW_RATIONAL);
     return G;
 }
@@ -364,5 +363,8 @@
     {
         if ( i.getItem().factor().inCoeffDomain() )
-            R.append( CFFactor( i.getItem().factor(), i.getItem().exp() ) );
+        {
+            if ( ! i.getItem().factor().isOne() )
+                R.append( CFFactor( i.getItem().factor(), i.getItem().exp() ) );
+        }
         else
         {
Index: factory/fac_multivar.h
===================================================================
--- factory/fac_multivar.h	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/fac_multivar.h	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -1,8 +1,9 @@
 /* emacs edit mode for this file is -*- C++ -*- */
+/* $Id: fac_multivar.h 12231 2009-11-02 10:12:22Z hannes $ */
 
 #ifndef INCL_FAC_MULTIVAR_H
 #define INCL_FAC_MULTIVAR_H
 
-// #include "config.h"
+#include <config.h>
 
 #include "canonicalform.h"
Index: factory/int_pp.h
===================================================================
--- factory/int_pp.h	(revision 4772b1b4621f2ab68acc9d2b5a568604d4d5e790)
+++ factory/int_pp.h	(revision 4a7a45801ea822129880f118ad38c3770af7226a)
@@ -30,9 +30,9 @@
     STATIC_VAR int prime;
     STATIC_VAR int exp;
+    static void initialize();
+public:
+    mpz_ptr MPI( const InternalCF * const c );
     STATIC_VAR mpz_t primepow;
     STATIC_VAR mpz_t primepowhalf;
-    static void initialize();
-    static mpz_ptr MPI( const InternalCF * const c );
-public:
     InternalPrimePower();
     InternalPrimePower( const InternalCF& )
@@ -91,5 +91,5 @@
 
     int sign() const;
-    friend mpz_ptr getmpi ( InternalCF * value, bool symmetric );
+    friend void getmpi ( InternalCF * value, mpz_t );
 };
 
