Index: factory/DegreePattern.cc
===================================================================
--- factory/DegreePattern.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/DegreePattern.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -17,5 +17,5 @@
 #include "DegreePattern.h"
 #include "cf_iter.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 #include "gfops.h"
 
Index: factory/DegreePattern.h
===================================================================
--- factory/DegreePattern.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/DegreePattern.h	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -21,5 +21,5 @@
 #include "canonicalform.h"
 #include "cf_iter.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 #include "gfops.h"
 
Index: factory/GNUmakefile.in
===================================================================
--- factory/GNUmakefile.in	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/GNUmakefile.in	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -261,7 +261,4 @@
 		ffops.h \
 		ffreval.h \
-		ftmpl_array.h \
-		ftmpl_factor.h \
-		ftmpl_functions.h \
 		ftmpl_list.h \
 		ftmpl_matrix.h \
Index: factory/canonicalform.cc
===================================================================
--- factory/canonicalform.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/canonicalform.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -421,4 +421,5 @@
 {
     int what = is_imm( value );
+#if 0
     if ( what )
         if ( what == FFMARK )
@@ -430,4 +431,15 @@
     else if ( value->inBaseDomain() )
         return value->degree();
+#else
+    switch(what)
+    {
+      case FFMARK: return imm_iszero_p( value ) ? -1 : 0;
+      case INTMARK: return imm_iszero( value ) ? -1 : 0;
+      case GFMARK:  return imm_iszero_gf( value ) ? -1 : 0;
+      case 0: if ( value->inBaseDomain() )
+              return value->degree();
+	      break;
+    }
+#endif
 
     Variable x = value->variable();
Index: factory/canonicalform.h
===================================================================
--- factory/canonicalform.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/canonicalform.h	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -21,8 +21,8 @@
 #include "cf_defs.h"
 #include "variable.h"
-#include "ftmpl_list.h"
-#include "ftmpl_array.h"
-#include "ftmpl_factor.h"
-#include "ftmpl_matrix.h"
+#include "templates/ftmpl_list.h"
+#include "templates/ftmpl_array.h"
+#include "templates/ftmpl_factor.h"
+#include "templates/ftmpl_matrix.h"
 
 /*BEGINPUBLIC*/
Index: factory/cf_algorithm.cc
===================================================================
--- factory/cf_algorithm.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/cf_algorithm.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -29,5 +29,5 @@
 #include "variable.h"
 #include "cf_iter.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 
 void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
Index: factory/cf_gcd.cc
===================================================================
--- factory/cf_gcd.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/cf_gcd.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -17,5 +17,5 @@
 #include "cf_algorithm.h"
 #include "fac_util.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 #include "ffreval.h"
 #include "algext.h"
Index: factory/cf_gcd_smallp.cc
===================================================================
--- factory/cf_gcd_smallp.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/cf_gcd_smallp.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -28,5 +28,5 @@
 #include "cf_map.h"
 #include "cf_util.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 #include "cf_random.h"
 #include "ffreval.h"
Index: factory/cf_map.cc
===================================================================
--- factory/cf_map.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/cf_map.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -15,5 +15,5 @@
 #include "cf_map.h"
 #include "cf_iter.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 
 //{{{ MapPair & MapPair::operator = ( const MapPair & p )
Index: factory/cf_map.h
===================================================================
--- factory/cf_map.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/cf_map.h	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -25,5 +25,5 @@
 #include "variable.h"
 #include "canonicalform.h"
-#include "ftmpl_list.h"
+#include "templates/ftmpl_list.h"
 
 /*BEGINPUBLIC*/
Index: factory/facFqBivarUtil.cc
===================================================================
--- factory/facFqBivarUtil.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/facFqBivarUtil.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -17,5 +17,5 @@
 #include "cf_map.h"
 #include "cf_map_ext.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 #include "ExtensionInfo.h"
 #include "cf_algorithm.h"
Index: factory/facHensel.h
===================================================================
--- factory/facHensel.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/facHensel.h	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -26,5 +26,5 @@
 #include "canonicalform.h"
 #include "cf_iter.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 #include "algext.h"
 
Index: factory/fac_ezgcd.cc
===================================================================
--- factory/fac_ezgcd.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/fac_ezgcd.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -15,5 +15,5 @@
 #include "cf_primes.h"
 #include "fac_distrib.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 
 static void findeval( const CanonicalForm & F, const CanonicalForm & G, CanonicalForm & Fb, CanonicalForm & Gb, CanonicalForm & Db, REvaluation & b, int delta, int degF, int degG );
Index: factory/ffreval.cc
===================================================================
--- factory/ffreval.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/ffreval.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -9,5 +9,5 @@
 #include "cf_primes.h"
 #include "fac_distrib.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 #include "ffreval.h"
 #include "cf_binom.h"
Index: ctory/ftmpl_array.h
===================================================================
--- factory/ftmpl_array.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ 	(revision )
@@ -1,18 +1,0 @@
-/* emacs edit mode for this file is -*- C++ -*- */
-/* $Id$ */
-
-#ifndef INCL_ARRAY_H
-
-//{{{ docu
-//
-// ftmpl_array.h - wrapper for `templates/ftmpl_array.h'.
-//
-// This file exists for convenience only.
-//
-// `INCL_ARRAY_H' is defined in `templates/ftmpl_array.h'.
-//
-//}}}
-
-#include "templates/ftmpl_array.h"
-
-#endif /* ! INCL_ARRAY_H */
Index: ctory/ftmpl_factor.h
===================================================================
--- factory/ftmpl_factor.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ 	(revision )
@@ -1,18 +1,0 @@
-/* emacs edit mode for this file is -*- C++ -*- */
-/* $Id$ */
-
-#ifndef INCL_FACTOR_H
-
-//{{{ docu
-//
-// ftmpl_factor.h - wrapper for `templates/ftmpl_factor.h'.
-//
-// This file exists for convenience only.
-//
-// `INCL_FACTOR_H' is defined in `templates/ftmpl_factor.h'.
-//
-//}}}
-
-#include "templates/ftmpl_factor.h"
-
-#endif /* ! INCL_FACTOR_H */
Index: ctory/ftmpl_functions.h
===================================================================
--- factory/ftmpl_functions.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ 	(revision )
@@ -1,18 +1,0 @@
-/* emacs edit mode for this file is -*- C++ -*- */
-/* $Id$ */
-
-#ifndef INCL_FUNCTIONS_H
-
-//{{{ docu
-//
-// ftmpl_functions.h - wrapper for `templates/ftmpl_functions.h'.
-//
-// This file exists for convenience only.
-//
-// `INCL_FUNCTIONS_H' is defined in `templates/ftmpl_functions.h'.
-//
-//}}}
-
-#include "templates/ftmpl_functions.h"
-
-#endif /* ! INCL_FUNCTIONS_H */
Index: ctory/ftmpl_list.h
===================================================================
--- factory/ftmpl_list.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ 	(revision )
@@ -1,129 +1,0 @@
-/* emacs edit mode for this file is -*- C++ -*- */
-/* $Id$ */
-
-#ifndef INCL_LIST_H
-#define INCL_LIST_H
-
-#include <factoryconf.h>
-
-#ifndef NOSTREAMIO
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define OSTREAM std::ostream
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define OSTREAM ostream
-#endif
-#endif /* NOSTREAMIO */
-
-template <class T>
-class ListIterator;
-
-template <class T>
-class List;
-
-#ifndef NOSTREAMIO
-template <class T>
-OSTREAM& operator<< ( OSTREAM &, const List<T> &);
-#endif
-
-template <class T>
-class ListItem
-{
-private:
-    ListItem * next;
-    ListItem * prev;
-    T * item;
-public:
-    ListItem( const ListItem<T>& );
-    ListItem( const T&, ListItem<T>*, ListItem<T>* );
-    ListItem( T* , ListItem<T>* , ListItem<T>* );
-    ~ListItem();
-    ListItem<T>& operator= ( const ListItem<T>& );
-    ListItem<T>* getNext();
-    ListItem<T>* getPrev();
-    T& getItem();
-#ifndef NOSTREAMIO
-    void print ( OSTREAM& );
-#endif /* NOSTREAMIO */
-    friend class ListIterator<T>;
-    friend class List<T>;
-};
-
-template <class T>
-class List
-{
-private:
-    ListItem<T> *first;
-    ListItem<T> *last;
-    int _length;
-public:
-    List();
-    List( const List<T>& );
-    List( const T& );
-    ~List();
-    List<T>& operator= ( const List<T>& );
-    void insert ( const T& );
-    void insert ( const T&, int (*cmpf)( const T&, const T& ) );
-    void insert ( const T&, int (*cmpf)( const T&, const T& ), void (*insf)( T&, const T& ) );
-    void append ( const T& );
-    int isEmpty() const;
-    int length() const;
-    T getFirst() const;
-    void removeFirst();
-    T getLast() const;
-    void removeLast();
-    void sort ( int (*) ( const T&, const T& ) );
-#ifndef NOSTREAMIO
-    void print ( OSTREAM & ) const;
-    friend OSTREAM& operator<< <T>( OSTREAM & os, const List<T> & l );
-#endif /* NOSTREAMIO */
-    friend class ListIterator<T>;
-};
-
-#ifndef NOSTREAMIO
-template <class T>
-OSTREAM& operator<< ( OSTREAM & os, const List<T> & l );
-#endif /* NOSTREAMIO */
-
-template <class T>
-class ListIterator {
-private:
-    List<T> *theList;
-    ListItem<T> *current;
-public:
-    ListIterator();
-    ListIterator( const ListIterator<T>& );
-    ListIterator( const List<T>& );
-    ~ListIterator();
-    ListIterator<T>& operator = ( const ListIterator<T>& );
-    ListIterator<T>& operator = ( const List<T>& );
-    T& getItem() const;
-    int hasItem();
-    void operator++();
-    void operator--();
-    void operator++( int );
-    void operator--( int );
-    void firstItem();
-    void lastItem();
-    void insert( const T& );
-    void append( const T& );
-    void remove( int moveright );
-};
-
-template <class T>
-List<T> Union ( const List<T>&, const List<T>& );
-
-template <class T>
-List<T> Difference ( const List<T>&, const List<T>& );
-
-template <class T>
-List<T> Union ( const List<T>&, const List<T>&, int (*cmpf)( const T&, const T& ), void (*insf)( T&, const T& ) );
-
-template <class T>
-T prod ( const List<T>& );
-
-template <class T>
-bool find (const List<T>&, const T& t);
-
-#endif /* ! INCL_LIST_H */
Index: ctory/ftmpl_matrix.h
===================================================================
--- factory/ftmpl_matrix.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ 	(revision )
@@ -1,96 +1,0 @@
-/* emacs edit mode for this file is -*- C++ -*- */
-/* $Id$ */
-
-#ifndef INCL_MATRIX_H
-#define INCL_MATRIX_H
-
-#include <factoryconf.h>
-
-#ifndef NOSTREAMIO
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define OSTREAM std::ostream
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define OSTREAM ostream
-#endif
-#endif /* NOSTREAMIO */
-
-template <class T>
-class SubMatrix;
-
-template <class T>
-class Matrix;
-
-#ifndef NOSTREAMIO
-template <class T>
-OSTREAM& operator<< (OSTREAM &, const Matrix<T> &);
-#endif
-
-template <class T>
-class Matrix
-{
-private:
-    int NR, NC;
-    T ** elems;
-#ifndef NOSTREAMIO
-    void printrow ( OSTREAM & s, int i ) const;
-#endif /* NOSTREAMIO */
-    typedef T* T_ptr;
-public:
-    Matrix() : NR(0), NC(0), elems(0) {}
-    Matrix( int nr, int nc );
-    Matrix( const Matrix<T>& M );
-    ~Matrix();
-    Matrix<T>& operator= ( const Matrix<T>& M );
-    int rows() const { return NR; }
-    int columns() const { return NC; }
-    SubMatrix<T> operator[] ( int i );
-    const SubMatrix<T> operator[] ( int i ) const;
-    T& operator() ( int row, int col );
-    T operator() ( int row, int col ) const;
-    SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax );
-    const SubMatrix<T> operator() ( int rmin, int rmax, int cmin, int cmax ) const;
-    void swapRow( int i, int j );
-    void swapColumn( int i, int j );
-#ifndef NOSTREAMIO
-    void print( OSTREAM& s ) const;
-    friend OSTREAM & operator<< <T>( OSTREAM & s, const Matrix<T>& M );
-#endif /* NOSTREAMIO */
-    friend class SubMatrix<T>;
-};
-    template <class T>
-    Matrix<T> operator+ ( const Matrix<T>& lhs, const Matrix<T>& rhs );
-    template <class T>
-    Matrix<T> operator- ( const Matrix<T>& lhs, const Matrix<T>& rhs );
-    template <class T>
-    Matrix<T> operator* ( const Matrix<T>& lhs, const Matrix<T>& rhs );
-    template <class T>
-    Matrix<T> operator* ( const Matrix<T>& lhs, const T& rhs );
-    template <class T>
-    Matrix<T> operator* ( const T& lhs, const Matrix<T>& rhs );
-
-template <class T>
-class SubMatrix
-{
-private:
-    int r_min, r_max, c_min, c_max;
-    Matrix<T>& M;
-    // we do not provide a default ctor, so nobody can declare an empty SubMatrix
-    SubMatrix( int rmin, int rmax, int cmin, int cmax, const Matrix<T> & m );
-public:
-    SubMatrix( const SubMatrix<T> & S );
-    SubMatrix<T>& operator= ( const SubMatrix<T>& S );
-    SubMatrix<T>& operator= ( const Matrix<T>& S );
-    operator Matrix<T>() const;
-    T operator[] ( int i ) const;
-    T& operator[] ( int i );
-    friend class Matrix<T>;
-};
-
-#ifndef NOSTREAMIO
-template <class T>
-OSTREAM & operator<< ( OSTREAM & s, const Matrix<T>& M );
-#endif /* NOSTREAMIO */
-
-#endif /* ! INCL_MATRIX_H */
Index: factory/int_intdiv.cc
===================================================================
--- factory/int_intdiv.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/int_intdiv.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -17,5 +17,5 @@
 #include "cf_gmp.h"
 #include "gmpext.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_functions.h"
 
 //{{{ InternalCF * InternalInteger::dividesame, dividecoeff ( InternalCF * c )
Index: factory/sm_sparsemod.cc
===================================================================
--- factory/sm_sparsemod.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/sm_sparsemod.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -28,6 +28,6 @@
 #include "sm_util.h"
 #include "sm_sparsemod.h"
-#include "ftmpl_array.h"
-#include "ftmpl_functions.h"
+#include "templates/ftmpl_array.h"
+#include "templates/ftmpl_functions.h"
 
 static CanonicalForm
Index: factory/sm_util.cc
===================================================================
--- factory/sm_util.cc	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/sm_util.cc	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -23,5 +23,5 @@
 #include "canonicalform.h"
 #include "variable.h"
-#include "ftmpl_array.h"
+#include "templates/ftmpl_array.h"
 
 //{{{ static CanonicalForm fmonome( const CanonicalForm & f  )
Index: factory/sm_util.h
===================================================================
--- factory/sm_util.h	(revision 3da413f2c6332c298e7f4115ffffdc526d5e914a)
+++ factory/sm_util.h	(revision 6db552749e12238ae3abecb5d2d439963bf140a4)
@@ -17,5 +17,5 @@
 #include "canonicalform.h"
 #include "cf_reval.h"
-#include "ftmpl_array.h"
+#include "templates/ftmpl_array.h"
 
 typedef Array<REvaluation> REArray;
