Index: kernel/old/old.CCRing.h
===================================================================
--- kernel/old/old.CCRing.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.CCRing.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,33 @@
+#ifndef CCRING_WRAP_HEADER
+#define CCRING_WRAP_HEADER
+#include <polys/monomials/ring.h>
+#include <kernel/grammar.h>
+#include <kernel/subexpr.h>
+#include <kernel/ipid.h>
+class Ring{
+  public:
+    ring pimpl;
+    Ring(ring r=currRing): pimpl(r){
+      if (r!=NULL)
+        ++(r->ref);
+    }
+    Ring(const Ring& r2):pimpl(r2.pimpl){
+      pimpl->ref++;
+    }
+    ~Ring(){
+      if (pimpl!=NULL)
+        --(pimpl->ref);
+    }
+    Ring & operator=(const Ring& r2){
+      r2.pimpl->ref++;
+      pimpl->ref--;
+      pimpl=r2.pimpl;
+    }
+   Ring & operator=(ring r2){
+      r2->ref++;
+      pimpl->ref--;
+      pimpl=r2;
+    }
+
+   };
+#endif
Index: kernel/old/old.IIntvec.h
===================================================================
--- kernel/old/old.IIntvec.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.IIntvec.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,29 @@
+#ifndef ITERATABLE_INTVEC_H
+#define ITERATABLE_INTVEC_H
+#include <vector>
+#include <misc/intvec.h>
+class Intvec: public std::vector<int>{
+public:
+  Intvec(iterator first,
+	iterator last,
+	const allocator_type& __a = allocator_type()):
+    std::vector<int>(first,last,__a){
+  }
+  Intvec(int n=0):std::vector<int>(n){}
+  Intvec(intvec& iv):std::vector<int>(iv.length()){
+    int n=iv.length();
+    for(int i=0;i<n;i++){
+      (*this)[i]=iv[i];
+    }
+  }
+  intvec* allocate_legacy_intvec_copy() const{
+    int s=size();
+    intvec* iv=new intvec(s);
+
+    for(int i=0;i<s;i++){
+      (*iv)[i]=(*this)[i];
+    }
+    return iv;
+  }
+};
+#endif
Index: kernel/old/old.Ideal.h
===================================================================
--- kernel/old/old.Ideal.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.Ideal.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,145 @@
+#ifndef IDEAL_CPP_HEADER
+#define IDEAL_CPP_HEADER
+#include <vector>
+#include <kernel/Poly.h>
+#include <kernel/ideals.h>
+//base for ideals as well for modules
+//doesn't need a destructor, as Polys will destroy itself
+template <class poly_type> class IdealBase {
+ protected:
+  std::vector<poly_type> storage;
+ public:
+  typedef poly_type value_type;
+  typedef typename std::vector<poly_type>::size_type size_type;
+  typedef typename std::vector<poly_type>::iterator iterator;
+  typedef typename std::vector<poly_type>::difference_type difference_type;
+  typedef typename std::vector<poly_type>::allocator_type allocator_type;
+ IdealBase(){
+ }
+
+ IdealBase(iterator first,
+             iterator last,
+             const typename
+             std::vector<poly_type>::allocator_type& __a = allocator_type()):
+   storage(first,last,__a)
+   {
+
+ }
+ ring getRing() const{
+  //FIXME: is a hack
+  if (size()>0){
+    return storage[0].getRing();
+  }
+  else
+  return (ring) NULL;
+ }
+ poly_type& operator[] (int n){
+   return storage[n];
+ }
+ const poly_type& operator[](int n) const{
+   return storage[n];
+ }
+ void push_back(const poly_type& p){
+   storage.push_back(p);
+ }
+ void push_front(const poly_type& p){
+   storage.push_front(p);
+ }
+
+ iterator begin(){
+   return storage.begin();
+ }
+ iterator end(){
+   return storage.end();
+ }
+ size_type size() const{
+   return storage.size();
+ }
+ iterator
+   insert(iterator __position, const value_type& __x){
+   return storage.insert(__position,__x);
+ }
+ iterator
+   erase(iterator __position){
+   return storage.erase(__position);
+ }
+ iterator
+   erase(iterator __first, iterator __last){
+   return storage.erase(__first,__last);
+ }
+ void insert(iterator __pos, iterator __first, iterator __last){
+   return insert(__pos,__first,__last);
+ }
+
+};
+
+class Ideal:
+public IdealBase<Poly>{
+ public:
+  Ideal(){
+  }
+  Ideal(ideal i, ring r){
+    for(int j=0;j<IDELEMS(i);j++){
+      storage.push_back(Poly(i->m[j],r));
+    }
+  }
+  Ideal(iterator first,
+        iterator last,
+        const allocator_type& __a = allocator_type()):
+    IdealBase<Poly>(first,last,__a){
+  }
+ ideal as_ideal() const{
+   //no checks for rings
+   int s=size();
+
+   if (s==0)
+    s=1;
+
+   ideal result=idInit(s,1);
+   result->m[0]=NULL;
+   s=size();
+   for(int i=0;i<s;i++){
+     result->m[i]=storage[i].as_poly();
+   }
+   return result;
+ }
+};
+class Module:
+public IdealBase<Vector>{
+public:
+ Module(ideal i, ring r){
+    for(int j=0;j<IDELEMS(i);j++){
+      storage.push_back(Vector(i->m[j],r));
+    }
+  }
+  ideal as_module() const{
+
+   //no checks for rings
+        int s=size();
+
+        if (s==0)
+        s=1;
+
+        ideal result=idInit(s,1);
+        result->m[0]=NULL;
+        s=size();
+        for(int i=0;i<s;i++){
+            result->m[i]=storage[i].as_poly();
+
+        }
+    if (size()==0)
+            result->rank=0;
+        else
+            result->rank=idRankFreeModule(result,storage[0].getRing());
+   return result;
+
+  }
+  Module(iterator first,
+        iterator last,
+        const allocator_type& __a = allocator_type()):
+    IdealBase<Vector>(first,last,__a){
+  }
+  Module(){
+  }
+};
+#endif
Index: kernel/old/old.Number.h
===================================================================
--- kernel/old/old.Number.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.Number.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,274 @@
+#ifndef NUMBERCPP_HEADER
+#define NUMBERCPP_HEADER
+#include <boost/intrusive_ptr.hpp>
+#include <kernel/mod2.h>
+#include <coeffs/numbers.h>
+#include <kernel/febase.h>
+#include <polys/monomials/ring.h>
+using namespace boost;
+inline void intrusive_ptr_add_ref(ring r){
+    r->ref++;
+    //Print("ref count after add: %d", r->ref);
+}
+inline void intrusive_ptr_release(ring r){
+    if (r->ref<=0) rDelete(r);
+    else {
+    r->ref--;
+
+    }
+    //Print("ref count after release: %d", r->ref);
+}
+
+enum poly_variant{
+  POLY_VARIANT_RING,
+  POLY_VARIANT_MODUL
+};
+template<poly_variant,class,class> class PolyBase;
+class Poly;
+//class TrivialErrorHandler;
+class Vector;
+class Number{
+
+ public:
+  friend Number operator+(const Number& n1, const Number& n2);
+  friend Number operator-(const Number& n1, const Number& n2);
+  friend Number operator/(const Number& n1, const Number& n2);
+  friend Number operator*(const Number& n1, const Number& n2);
+  friend bool operator==(const Number& n1, const Number& n2);
+  friend Number operator+(const Number& n1, int n2);
+  friend Number operator-(const Number& n1, int n2);
+  friend Number operator/(const Number& n1, int n2);
+  friend Number operator*(const Number& n1, int n2);
+  friend bool operator==(const Number& n1, int n2);
+  friend Number operator+(int n1, const Number& n2);
+  friend Number operator-(int n1, const Number& n2);
+  friend Number operator/(int n1, const Number& n2);
+  friend Number operator*(int n1, const Number& n2);
+  friend bool operator==(int n1, const Number& n2);
+  friend class Poly;
+  friend class Vector;
+  //friend class PolyBase<POLY_VARIANT_RING,Poly,TrivialErrorHandler>;
+//   friend class PolyBase <poly_variant variant,
+//   class create_type_input,
+//   class error_handle_traits>;
+   template <poly_variant,class,class> friend class PolyBase;
+  friend class PolyImpl;
+  number as_number() const{
+    return n_Copy(n,r.get());
+  }
+  Number& operator=(const Number& n2){
+    //durch Reihenfolge Selbstzuweisungen berücksichtigt
+    number nc=n_Copy(n2.n,n2.r.get());
+    n_Delete(&n,r.get());
+    r=n2.r;
+    n=nc;
+    return *this;
+  }
+  Number operator-(){
+    Number t(*this);
+    //t.n=n_Copy(n,r);
+    t.n=n_Neg(t.n,r.get());
+    return t;
+  }
+  Number& operator+=(const Number & n2){
+    if (r!=n2.r){
+      Werror("not the same ring");
+      return *this;
+    }
+    number nv=n_Add(n,n2.n,r.get());
+    n_Delete(&n,r.get());
+    n=nv;
+    return *this;
+  }
+  Number& operator*=(const Number & n2){
+    if (r!=n2.r){
+      Werror("not the same ring");
+      return *this;
+    }
+    number nv=n_Mult(n,n2.n,r.get());
+    n_Delete(&n,r.get());
+    n=nv;
+    return *this;
+  }
+  Number& operator-=(const Number & n2){
+    if (r!=n2.r){
+      Werror("not the same ring");
+      return *this;
+    }
+    number nv=n_Sub(n,n2.n,r.get());
+    n_Delete(&n,r.get());
+    n=nv;
+    return *this;
+  }
+  Number& operator/=(const Number & n2){
+    if (r!=n2.r){
+      Werror("not the same ring");
+      return *this;
+    }
+    number nv=n_Div(n,n2.n,r.get());
+    n_Delete(&n,r.get());
+    n=nv;
+    return *this;
+  }
+
+  Number& operator=(int n2){
+    n_Delete(&n,r.get());
+    n=n_Init(n2,r.get());
+    return *this;
+  }
+
+  Number& operator+=(int n2){
+    number n2n=n_Init(n2,r.get());
+    number nv=n_Add(n,n2n,r.get());
+    n_Delete(&n,r.get());
+    n_Delete(&n2n,r.get());
+    n=nv;
+    return *this;
+  }
+  Number& operator*=(int n2){
+    number n2n=n_Init(n2,r.get());
+    number nv=n_Mult(n,n2n,r.get());
+    n_Delete(&n,r.get());
+    n_Delete(&n2n,r.get());
+    n=nv;
+    return *this;
+  }
+  Number& operator-=(int n2){
+
+    number n2n=n_Init(n2,r);
+    number nv=n_Sub(n,n2n,r);
+    n_Delete(&n,r.get());
+    n_Delete(&n2n,r.get());
+    n=nv;
+    return *this;
+  }
+  Number& operator/=(int n2){
+    number n2n=n_Init(n2,r.get());
+    number nv=n_Div(n,n2n,r.get());
+    n_Delete(&n,r.get());
+    n_Delete(&n2n,r.get());
+    n=nv;
+    return *this;
+  }
+
+
+
+  Number(){
+    r=currRing;
+    if (r.get()!=NULL)
+      n=n_Init(0,r.get());
+    else
+      n=(number) NULL;
+  }
+  Number(const Number & n){
+    r=n.r;
+    this->n=n_Copy(n.n,r.get());
+  }
+  Number(number n, ring r){
+    this->n=n_Copy(n,r);
+    this->r=r;
+  }
+  Number(int n, ring r){
+
+    this->r=r;
+    this->n=n_Init(n,r);
+  }
+  Number(int n, intrusive_ptr<ip_sring> r){
+    this->r=r;
+    this->n=n_Init(n,r.get());
+
+  }
+  explicit Number(int n){
+    r=currRing;
+    this->n=n_Init(n,r.get());
+  }
+  void write() const{
+    number towrite=n;
+    n_Write(towrite,r.get());
+  }
+
+  ~Number(){
+    if (r!=NULL)
+      n_Delete(&n,r.get());
+  }
+ ring getRing() const{
+    return r.get();
+ }
+ protected:
+  number n;
+  intrusive_ptr<ip_sring> r;
+
+};
+
+inline Number operator+(const Number &n1, const Number& n2){
+  Number erg(n1);
+  erg+=n2;
+  return erg;
+}
+inline Number operator*(const Number &n1, const Number& n2){
+  Number erg(n1);
+  erg*=n2;
+  return erg;
+}
+inline Number operator-(const Number &n1, const Number& n2){
+  Number erg(n1);
+  erg-=n2;
+  return erg;
+}
+inline Number operator/(const Number &n1, const Number& n2){
+  Number erg(n1);
+  erg/=n2;
+  return erg;
+}
+inline bool operator==(const Number &n1, const Number& n2){
+  if(n1.r!=n2.r)
+    return false;
+  return n_Equal(n1.n,n2.n,n1.r);
+}
+
+
+inline Number operator+(const Number &n1, int n2){
+  Number erg(n1);
+  erg+=Number(n2,n1.r);
+  return erg;
+}
+inline Number operator*(const Number &n1, int n2){
+  Number erg(n1);
+  erg*=Number(n2,n1.r);
+  return erg;
+}
+inline Number operator-(const Number &n1, int n2){
+  Number erg(n1);
+  erg-=Number(n2,n1.r);
+  return erg;
+}
+inline Number operator/(const Number &n1, int n2){
+  Number erg(n1);
+  erg/=Number(n2,n1.r);
+  return erg;
+}
+inline bool operator==(const Number &n1, int n2){
+  return n_Equal(n1.n,Number(n2,n1.r).n,n1.r);
+}
+inline Number operator+(int n1, const Number& n2){
+  Number erg(n2);
+  return erg+=Number(n1,n2.r);
+}
+inline Number operator-(int n1, const Number& n2){
+
+  Number erg(n1,n2.r);
+  return erg-=n2;
+}
+inline Number operator/(int n1, const Number& n2){
+  Number erg(n1,n2.r);
+  return erg/=n2;
+}
+
+inline Number operator*(int n1, const Number& n2){
+  Number erg(n2);
+  return erg*=Number(n1,n2.r);
+}
+inline bool operator==(int n1, const Number& n2){
+  return n2==Number(n1,n2.r);
+}
+#endif
Index: kernel/old/old.Poly.h
===================================================================
--- kernel/old/old.Poly.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.Poly.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,620 @@
+
+
+
+#ifndef POLYCPP_HEADER
+#define POLYCPP_HEADER
+#include <kernel/mod2.h>
+#include <kernel/IIntvec.h>
+#include <coeffs/numbers.h>
+#include <kernel/Number.h>
+#include <kernel/febase.h>
+#include <kernel/polys.h>
+#include <polys/monomials/ring.h>
+
+
+#include <boost/shared_ptr.hpp>
+
+#include <vector>
+#include <exception>
+using std::exception;
+
+#define BOOST_DISABLE_THREADS
+
+class DifferentDomainException: public exception{
+
+};
+class ExceptionBasedErrorHandler{
+    public:
+        static const bool handleErrors=true;
+        static void handleDifferentRing(ring r, ring s){
+        PrintS("throwing");
+        throw DifferentDomainException();
+    }
+};
+
+//PolyImpl is a 08/15 poly wrapper
+//Poly wraps around PolyImpl with reference counting using boost
+class TrivialErrorHandler{
+    public:
+    static const bool handleErrors=false;
+    static void handleDifferentRing(ring r, ring s){
+    }
+};
+typedef TrivialErrorHandler MyErrorHandler;
+class PolyImpl{
+  template <poly_variant,class,class> friend class PolyBase;
+  //friend class PolyBase<POLY_VARIANT_RING,Poly,TrivialErrorHandler>;
+  //friend class PolyBase<POLY_VARIANT_MODUL,Vector, TrivialErrorHandler>;
+  //friend class PolyBase<POLY_VARIANT_MODUL>;
+  friend class Poly;
+  friend class Vector;
+  //friend class Number;
+ protected:
+  poly getInternalReference() const{
+    return p;
+  }
+ public:
+  ring getRing() const{
+    return r.get();
+  }
+  friend inline bool operator==(const Poly& p1, const Poly& p2);
+  friend inline bool operator==(const Vector& p1, const Vector& p2);
+  friend PolyImpl operator+(const PolyImpl& p1, const PolyImpl& n2);
+  friend PolyImpl operator-(const PolyImpl& p1, const PolyImpl& n2);
+  friend PolyImpl operator/(const PolyImpl& p1, const PolyImpl& n2);
+  friend PolyImpl operator*(const PolyImpl& p1, const PolyImpl& n2);
+  friend bool operator==(const PolyImpl& p1, const PolyImpl& n2);
+  friend PolyImpl operator+(const PolyImpl& p1, int n2);
+  friend PolyImpl operator-(const PolyImpl& p1, int n2);
+  friend PolyImpl operator/(const PolyImpl& p1, int n2);
+  friend PolyImpl operator*(const PolyImpl& p1, int n2);
+  friend bool operator==(const PolyImpl& p1, int n2);
+  Number leadCoef(){
+    return Number(p->coef,r.get());
+  }
+  PolyImpl& operator=(const PolyImpl& p2){
+    //durch Reihenfolge Selbstzuweisungen berücksichtigt
+    if (this==&p2) return *this;
+    poly pc=p_Copy(p2.p,p2.r.get());
+    if(r!=NULL)
+      p_Delete(&p,r.get());
+    r=p2.r;
+    p=pc;
+    return *this;
+  }
+  PolyImpl operator-(){
+    PolyImpl t(*this);
+    t.p=p_Copy(p,r.get());
+    t.p=p_Neg(t.p,r.get());
+    return t;
+  }
+  PolyImpl& operator+=(const PolyImpl & p2){
+    if (r!=p2.r){
+      Werror("not the same ring");
+      return *this;
+    }
+    if (this==&p2){
+      number two=n_Init(2,r.get());
+      p_Mult_nn(p,two,r.get());
+      return *this;
+    }
+    p=p_Add_q(p,p_Copy(p2.p,p2.r.get()),r.get());
+
+    return *this;
+  }
+  PolyImpl& operator*=(const PolyImpl & p2){
+    if (r!=p2.r){
+      Werror("not the same ring");
+      return *this;
+    }
+    if (this==&p2){
+      poly pc=p_Copy(p,r.get());
+      p=p_Mult_q(p,p2.p,r.get());
+      return *this;
+    }
+    p=p_Mult_q(p,p_Copy(p2.p,p2.r.get()),r.get());
+    return *this;
+  }
+  PolyImpl& operator*=(const Number & n){
+    if (r!=n.r){
+      Werror("not the same ring");
+      return *this;
+    }
+
+    p=p_Mult_nn(p,n.n,r.get());
+    return *this;
+  }
+  PolyImpl& operator-=(const PolyImpl & p2){
+    if (r!=p2.r){
+      Werror("not the same ring");
+      return *this;
+    }
+    if (this==&p2){
+      p_Delete(&p,r.get());
+      p=NULL;
+      return *this;
+    }
+
+    poly pc=p_Copy(p2.p,p2.r.get());
+    pc=p_Neg(pc,r.get());
+    p=p_Add_q(p,pc,r.get());
+
+
+    return *this;
+  }
+
+
+  PolyImpl& operator=(int n){
+
+    p_Delete(&p,r.get());
+    p=p_ISet(n,r.get());
+    return *this;
+
+  }
+
+
+  PolyImpl(){
+    r=currRing;
+    p=NULL;
+  }
+  PolyImpl(const PolyImpl & p){
+    r=p.r;
+    this->p=p_Copy(p.p,r.get());
+  }
+  PolyImpl(poly p, intrusive_ptr<ip_sring> r){
+    this->p=p_Copy(p,r.get());
+    this->r=r;
+  }
+  PolyImpl(poly p, intrusive_ptr<ip_sring> r,int){
+    this->p=p;
+    this->r=r;
+  }
+  PolyImpl(int n, intrusive_ptr<ip_sring> r){
+    this->p=p_ISet(n,r.get());
+    this->r=r;
+  }
+  PolyImpl(const Number & n){
+
+    r=n.r.get();
+    this->p=p_NSet(n_Copy(n.n,r.get()),r.get());
+
+  }
+  explicit PolyImpl(int n){
+    r=currRing;
+    this->p=p_ISet(n,r.get());
+  }
+  void print(){
+    p_Write(p,r.get(),r.get());
+  }
+
+  virtual ~PolyImpl(){
+    if (r!=NULL)
+      p_Delete(&p,r.get());
+  }
+
+ protected:
+  poly p;
+  intrusive_ptr<ip_sring> r;
+
+};
+
+inline PolyImpl operator+(const PolyImpl &p1, const PolyImpl& p2){
+  PolyImpl erg(p1);
+  erg+=p2;
+  return erg;
+}
+inline PolyImpl operator*(const PolyImpl &p1, const PolyImpl& p2){
+  PolyImpl erg(p1);
+  erg*=p2;
+  return erg;
+}
+inline PolyImpl operator-(const PolyImpl &p1, const PolyImpl& p2){
+  PolyImpl erg(p1);
+  erg-=p2;
+  return erg;
+}
+
+
+
+inline PolyImpl operator+(const PolyImpl &p1, int p2){
+  PolyImpl erg(p1);
+  erg+=PolyImpl(p2,p1.r.get());
+  return erg;
+}
+inline PolyImpl operator*(const PolyImpl &p1, int p2){
+  PolyImpl erg(p1);
+  erg*=PolyImpl(p2,p1.r.get());
+  return erg;
+}
+inline PolyImpl operator-(const PolyImpl &p1, int p2){
+  PolyImpl erg(p1);
+  erg-=PolyImpl(p2,p1.r);
+  return erg;
+}
+
+
+inline PolyImpl operator+(int p1, const PolyImpl& p2){
+  PolyImpl erg(p2);
+  return erg+=PolyImpl(p1,p2.getRing());
+}
+
+inline PolyImpl operator*(int p1, const PolyImpl& p2){
+  PolyImpl erg(p2);
+  return erg*=PolyImpl(p1,p2.getRing());
+}
+
+using namespace boost;
+
+
+template<class T> class ConstTermReference{
+ private:
+  ring r;
+  poly t;
+ public:
+  operator T() const {
+    return T(p_Head(t,r),r);
+  }
+  ConstTermReference(poly p, ring r){
+    this->t=p;
+    this->r=r;
+  }
+  bool isConstant() const{
+    return p_LmIsConstant(t,r);
+  }
+
+};
+
+template<class T> class PolyInputIterator:
+public std::iterator<std::input_iterator_tag,T,int, shared_ptr<const T>,ConstTermReference<T> >
+{
+
+
+ private:
+  poly t;
+  ring r;
+  public:
+  bool operator==(const PolyInputIterator& t2){
+    return t2.t==t;
+  }
+  bool operator!=(const PolyInputIterator& t2){
+    return t2.t!=t;
+  }
+  PolyInputIterator(poly p, ring r){
+    t=p;
+    this->r=r;
+  }
+  PolyInputIterator(const PolyInputIterator& it){
+    t=it.t;
+    r=it.r;
+  }
+  PolyInputIterator& operator++(){
+    t=t->next;
+    return *this;
+  }
+  PolyInputIterator operator++(int){
+    PolyInputIterator it(*this);
+    ++(*this);
+    return it;
+  }
+  const ConstTermReference<T> operator*(){
+    return ConstTermReference<T> (t,r);
+  }
+  shared_ptr<const T> operator->(){
+    return shared_ptr<const T>(new T(p_Head(t,r),r,0));
+  }
+
+};
+
+template<poly_variant variant, class create_type_input, class error_handle_traits> class PolyBase{
+ private:
+    typedef PolyBase<variant,create_type_input,error_handle_traits> ThisType;
+ public:
+  poly as_poly() const{
+    return p_Copy(ptr->p,ptr->getRing());
+  }
+  template<class T> void checkIsSameRing(T& p){
+    if (error_handle_traits::handleErrors){
+                 if (p.getRing()!=this->getRing()){
+   error_handle_traits::handleDifferentRing(
+    this->getRing(),
+    p.getRing()
+   );
+        }
+    }
+  }
+  typedef create_type_input create_type;
+  typedef PolyInputIterator<create_type> iterator;
+  Intvec leadExp(){
+    int nvars=rVar(ptr->r);
+    Intvec res(nvars);
+    for(int i=0;i<nvars;i++){
+      res[i]=p_GetExp(ptr->p,i+1,ptr->getRing());
+    }
+    return res;
+  }
+  void copy_on_write(){
+    if (!ptr.unique()){
+      ptr.reset(new PolyImpl(*ptr));
+    }
+  }
+  void print() const {
+    ptr->print();
+  }
+  //* ressource managed by Singular
+  char* c_string() const{
+
+    return p_String(ptr->p,ptr->getRing(),ptr->getRing());
+  }
+
+  PolyBase(ring r=currRing):ptr(new PolyImpl((poly) NULL,r)){
+  }
+
+  PolyBase(const char* c, ring r=currRing):ptr(new PolyImpl((poly)NULL,r)){
+    //p_Read takes no const so do
+    char* cp=(char*) omalloc((strlen(c)+1)*sizeof(char));
+    strcpy(cp,c);
+    p_Read(cp,ptr->p,r);
+    omfree(cp);
+  }
+  PolyBase(const PolyBase&p):ptr(p.ptr){
+  }
+
+
+
+  PolyBase& operator+=(const PolyBase& p2){
+    checkIsSameRing(p2);
+    copy_on_write();
+    *ptr += *p2.ptr;
+
+    return *this;
+  }
+  PolyBase& operator*=(const Poly & p2);
+  PolyBase& operator*=(Number n){
+    copy_on_write();
+    *ptr *=n;
+
+    return *this;
+  }
+  /*  void print(){
+     StringSetS("");
+     write();
+     { char* s = StringEndS(); PrintS(s); omFree(s); }
+     }*/
+  virtual ~PolyBase(){}
+  PolyBase(poly p, ring r):ptr(new PolyImpl(p_Copy(p,r),r)){
+  }
+  PolyBase(poly p, ring r,int):ptr(new PolyImpl(p,r,0)){
+  }
+  /*Poly(Poly& p){
+    ptr=p.ptr;
+    }*/
+
+  PolyInputIterator<create_type> begin(){
+    return PolyInputIterator<create_type>(ptr->p,ptr->getRing());
+  }
+  PolyInputIterator<create_type> end(){
+    return PolyInputIterator<create_type>(NULL, ptr->getRing());
+  }
+  ring getRing() const{
+    return ptr->getRing();
+  }
+  int lmTotalDegree() const{
+    return pTotaldegree(ptr->p);
+  }
+  Number leadCoef(){
+    return ptr->leadCoef();
+  }
+  create_type operator-(){
+    create_type erg(*this);
+    erg*=Number(-1,ptr->getRing());
+    return erg;
+  }
+ protected:
+
+  PolyBase(PolyImpl& impl):ptr(&impl){
+
+  }
+  poly getInternalReference(){
+    return ptr->getInternalReference();
+  }
+ protected:
+
+  shared_ptr<PolyImpl> ptr;
+
+};
+
+class Poly: public PolyBase<POLY_VARIANT_RING, Poly, MyErrorHandler>{
+ private:
+    typedef PolyBase<POLY_VARIANT_RING, Poly,MyErrorHandler> Base;
+  friend class Vector;
+  friend class PolyBase<POLY_VARIANT_MODUL,Vector,MyErrorHandler>;
+ public:
+
+  Poly(ring r=currRing):Base ((poly)NULL,r,0){
+  }
+  Poly(int n, ring r=currRing):Base(*(new PolyImpl(n,r))){
+
+  }
+  Poly(const char* c, ring r=currRing):Base(c,r){
+
+  }
+  Poly(const Base& p):Base(p){
+  }
+
+  Poly(const Number& n):Base(*(new PolyImpl(n))){
+
+  }
+  Poly(poly p, ring r):Base(p,r){
+
+  }
+  Poly(poly p, ring r, int):Base(p,r,0){
+  }
+  Poly(const std::vector<int>& v, ring r=currRing):Base(*(new PolyImpl((poly) NULL,r))){
+    unsigned int i;
+    int s=v.size();
+    poly p=p_ISet(1,r);
+    for(i=0;i<v.size();i++){
+      pSetExp(p,i+1,v[i]);
+    }
+    pSetm(p);
+    ptr.reset(new PolyImpl(p,r));
+  }
+  /*  Poly& operator+=(const Number& n){
+  Poly p2(n);
+  ((PolyBase<POLY_VARIANT_RING, Poly>&) (*this))+=p2;
+  return *this;
+  }*/
+  Poly& operator+=(const Poly& p ){
+
+    ((Base&)*this)+=p;
+    return *this;
+  }
+  Poly& operator+=(const Base& p ){
+
+    ((Base&)*this)+=p;
+    return *this;
+  }
+  friend inline bool operator==(const Poly& p1, const Poly& p2);
+
+};
+class Vector: public PolyBase<POLY_VARIANT_MODUL, Vector, MyErrorHandler>{
+ private:
+    typedef PolyBase<POLY_VARIANT_MODUL, Vector, MyErrorHandler> Base;
+ public:
+
+  Vector(ring r=currRing):Base ((poly)NULL,r,0){
+  }
+  Vector(int n, ring r=currRing):Base(*(new PolyImpl(n,r))){
+
+  }
+  Vector(const char* c, ring r=currRing):Base(c,r){
+
+  }
+  Vector(const Base& p):Base(p){
+  }
+
+
+  Vector(poly p, ring r):Base(p,r){
+
+  }
+  Vector(poly p, ring r, int):Base(p,r,0){
+  }
+  Vector(std::vector<int> v, ring r=currRing):Base(*(new PolyImpl((poly) NULL,r))){
+    unsigned int i;
+    int s=v.size();
+    poly p=p_ISet(1,r);
+    for(i=0;i<v.size();i++){
+      pSetExp(p,i+1,v[i]);
+    }
+    pSetm(p);
+    ptr.reset(new PolyImpl(p,r));
+  }
+  /*  Poly& operator+=(const Number& n){
+  Poly p2(n);
+  ((PolyBase<POLY_VARIANT_MODUL, Poly>&) (*this))+=p2;
+  return *this;
+  }*/
+  Vector& operator+=(const Vector& p ){
+
+    ((Base&)*this)+=p;
+    return *this;
+  }
+  Vector& operator+=(const Base& p ){
+
+    ((Base&)*this)+=p;
+    return *this;
+  }
+  friend inline bool operator==(const Vector& p1, const Vector& p2);
+};
+
+//typedef Poly PolyBase<POLY_VARIANT_RING>::create_type;
+/*template <poly_variant v, class c> inline PolyBase<v> operator+(const PolyBase<v,c>& p1, const PolyBase<v,c>& p2){
+    PolyImpl* res=new PolyImpl(*p1.ptr);
+    *res+=*p2.ptr;
+    return(PolyBase<v,c>(*res));
+    }*/
+/*template <poly_variant v> inline PolyBase<v> operator*(const PolyBase<v>& p1, const PolyBase<v>& p2){
+    PolyImpl* res=new PolyImpl(*p1.ptr);
+    *res *= *p2.ptr;
+    return(PolyBase<v> (*res));
+    }*/
+/*template <class c> inline PolyBase<POLY_VARIANT_MODUL> operator*(const PolyBase<POLY_VARIANT_MODUL>& p1, const Number& n){
+  PolyBase<POLY_VARIANT_MODUL> erg(p1);
+  erg*=n;
+  return erg;
+  }*/
+inline Poly operator*(const Poly& p, const Poly& p2){
+  Poly erg=p;
+  erg*=p2;
+  return erg;
+}
+inline Vector operator*(const Number& n, const Vector& v){
+  Vector res=v;
+  res*=n;
+  return res;
+}
+
+//assumes monomials commute with numbers
+template <poly_variant variant, class create_type, class error_traits>
+  inline typename PolyBase<variant,create_type, error_traits>::create_type
+  operator*
+  (const Number& n,
+   const PolyBase<variant,create_type, class error_tratis>& p)
+{
+  typename PolyBase<variant, create_type,error_traits>::create_type erg(p);
+  erg*=n;
+  return erg;
+}
+
+inline Vector operator*(const Poly& p, const Vector& v){
+  Vector res(v);
+  res*=p;
+  return res;
+}
+inline Poly operator+(const Poly& p1, const Number& n){
+ Poly f(p1);
+  f+=n;
+  return f;
+  }
+inline bool operator==(const Poly& p1, const Poly& p2){
+  ring r1=p1.getRing();
+  ring r2=p2.getRing();
+  if (r1!=r2) return false;
+  return p_EqualPolys(p1.ptr->p,p2.ptr->p,r1);
+}
+inline bool operator==(const Vector& p1, const Vector& p2){
+  ring r1=p1.getRing();
+  ring r2=p2.getRing();
+  if (r1!=r2) return false;
+  return p_EqualPolys(p1.ptr->p,p2.ptr->p,r1);
+}
+template <poly_variant variant, class create_type,class error_traits>
+  inline typename PolyBase<variant,create_type,error_traits>::create_type
+  operator+
+  (const PolyBase<variant,create_type,error_traits>& b1,
+   const PolyBase<variant,create_type,error_traits>& b2)
+{
+  typename PolyBase<variant, create_type, error_traits>::create_type erg(b1);
+  erg+=b2;
+  return erg;
+}
+inline Vector unitVector(int i,ring r=currRing){
+  poly p=p_ISet(1,r);
+  p_SetComp(p,i,r);
+  return Vector(p,r,0);
+}
+inline Poly operator*(const Number& n, const Poly & p){
+  Poly res=p;
+  res*=n;
+  return res;
+}
+template <poly_variant variant, class create_type, class error_traits>
+
+inline PolyBase<variant, create_type, error_traits>&
+PolyBase<variant, create_type, error_traits>::operator*=(const Poly & p2){
+    copy_on_write();
+    *ptr *= *p2.ptr;
+ 
+    return *this;
+  }
+#endif
Index: kernel/old/old.PowerSeries.h
===================================================================
--- kernel/old/old.PowerSeries.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.PowerSeries.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,175 @@
+#ifndef POWER_SERIES_HEADER
+#define POWER_SERIES_HEADER
+#include <kernel/mod2.h>
+#include <kernel/Poly.h>
+template <class traits> class PowerSeriesInputIterator:
+public std::
+iterator<
+  std::input_iterator_tag,
+  typename traits::expansion_type,
+  int,
+  shared_ptr<const typename traits::expansion_type>,
+  const typename traits::expansion_type
+  > {
+ private:
+  typedef typename traits::denominator_type denominator_type;
+  typedef typename traits::numerator_type numerator_type;
+  typedef typename traits::expansion_type expansion_type;
+  denominator_type denominator;
+  numerator_type numerator;
+  denominator_type toPot;
+  int state;
+  expansion_type data;
+  denominator_type lastPot;
+ public:
+  PowerSeriesInputIterator(numerator_type num_arg,
+                           denominator_type den_arg):
+    data(den_arg.getRing()),
+    lastPot(den_arg.getRing()),
+    numerator(num_arg),
+    denominator(den_arg){
+
+    ring r=denominator.getRing();
+
+    //not the lead coef    Number c=denominator.leadCoef();
+    Number c(1,r);
+    typename traits::denominator_type::iterator it=denominator.begin();
+    typename traits::denominator_type::iterator end=denominator.end();
+    while(it!=end){
+
+      if ((*it).isConstant()){
+        //change this type
+        c=denominator_type(*it).leadCoef();
+
+        break;
+      }
+
+      ++it;
+
+
+
+    }
+    c=Number(1,r)/c;
+    numerator*=c;
+    denominator*=c;
+    toPot=denominator+denominator_type(-1,r);
+
+    toPot*=Number(-1,r);
+    //change this type
+    lastPot=denominator_type(1,r);
+    data=numerator;
+    state=0;
+
+  }
+  PowerSeriesInputIterator(){
+    state=-1;
+  }
+  void shorten(){
+    typename expansion_type::iterator it=data.begin();
+    typename expansion_type::iterator end=data.end();
+    ring r=data.getRing();
+    expansion_type remove(r);
+    while(it!=end){
+      if(it->lmTotalDegree()<state){
+        remove+=expansion_type(*it);
+      }
+      it++;
+    }
+    remove*=Number(-1,r);
+    data+=remove;
+  }
+  expansion_type getValue(){
+    typename expansion_type::iterator it=data.begin();
+    typename expansion_type::iterator end=data.end();
+    ring r=data.getRing();
+    expansion_type res(r);
+    while(it!=end){
+      if(it->lmTotalDegree()==state)
+        {
+          res+=expansion_type(*it);
+        }
+      it++;
+    }
+    return res;
+  }
+  PowerSeriesInputIterator& operator++(){
+    state++;
+    shorten();
+    lastPot*=toPot;
+
+    data+=lastPot*numerator;
+
+
+    return *this;
+
+  }
+  //bad if this are iterators for different PowerSeries
+  bool operator==(const PowerSeriesInputIterator& t2){
+    return state==t2.state;
+  }
+  bool operator!=(const PowerSeriesInputIterator& t2){
+    return state!=t2.state;
+  }
+
+
+
+  PowerSeriesInputIterator operator++(int){
+    PowerSeriesInputIterator it(*this);
+    ++(*this);
+    return it;
+  }
+  const expansion_type operator*(){
+    return expansion_type(getValue());
+  }
+  shared_ptr<const expansion_type> operator->(){
+    return shared_ptr<const expansion_type>(new expansion_type(getValue()));
+  }
+  };
+
+
+template<class traits> class PowerSeriesBase{
+ public:
+  typedef typename traits::denominator_type denominator_type;
+  typedef typename traits::numerator_type numerator_type;
+ protected:
+  denominator_type denominator;
+  numerator_type numerator;
+ public:
+
+  PowerSeriesBase(){
+  }
+  PowerSeriesBase(const numerator_type &a, const denominator_type & b):numerator(a),denominator(b){
+    assume(a.getRing()==b.getRing());
+    //asume b!=NULL
+  }
+  typedef PowerSeriesInputIterator<traits> iterator;
+  iterator begin(){
+    return iterator(numerator,denominator);
+  }
+  iterator end(){
+    return iterator();
+  }
+
+
+};
+class PowerSeriesPolyTraits;
+class PowerSeriesVectorTraits;
+typedef PowerSeriesBase<PowerSeriesPolyTraits> PowerSeries;
+typedef PowerSeriesBase<PowerSeriesVectorTraits> VectorPowerSeries;
+class PowerSeriesPolyTraits{
+ public:
+  typedef Poly numerator_type;
+  typedef Poly denominator_type;
+  typedef PowerSeries create_type;
+  typedef Poly expansion_type;
+};
+class PowerSeriesVectorTraits{
+ public:
+  typedef Vector numerator_type;
+  typedef Poly denominator_type;
+  typedef VectorPowerSeries create_type;
+  typedef Vector expansion_type;
+};
+
+
+#endif
Index: kernel/old/old.lplist.cc
===================================================================
--- kernel/old/old.lplist.cc	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.lplist.cc	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,130 @@
+/****************************************
+*  Computer Algebra System SINGULAR     *
+****************************************/
+/*
+* ABSTRACT: list interface
+*/
+#ifdef HAVE_CONFIG_H
+#include "singularconfig.h"
+#endif /* HAVE_CONFIG_H */
+#include <kernel/mod2.h>
+
+#ifdef HAVE_F5
+
+#include <kernel/GBEngine/kutil.h>
+#include <kernel/structs.h>
+#include <omalloc/omalloc.h>
+#include <kernel/polys.h>
+#include <polys/monomials/p_polys.h>
+#include <kernel/ideals.h>
+#include <kernel/febase.h>
+#include <kernel/GBEngine/kstd1.h>
+#include <kernel/GBEngine/khstd.h>
+#include <polys/kbuckets.h>
+#include <polys/weight.h>
+#include <misc/intvec.h>
+#include <kernel/polys.h>
+#include <kernel/lpolynomial.h>
+#include <kernel/lplist.h>
+
+
+/*
+=========================================
+=========================================
+implementation of the functions of list.h
+=========================================
+=========================================
+*/
+
+
+
+
+/*
+===========================
+insert general node in list
+===========================
+*/
+Node* GenNode::insert(LPoly* d) {
+    int ret = data->compare(*d);
+    switch(ret) {
+        case 0: case -1: {
+            next = next->insert(d);
+            return this;
+        }
+        case 1: {   
+            GenNode* newNode = new GenNode(d,this);
+            return newNode;
+        }
+    }            
+    return this;
+}
+
+/*
+========================
+get general node in list
+========================
+*/
+void GenNode::get() {
+    data->get();
+    next->get();
+}
+
+/*
+=========================
+insert first node in list
+=========================
+*/
+Node* FirstNode::insert(LPoly* d) {
+    next = next->insert(d);
+    return this;
+}
+
+/*
+===========================================================================================
+get first node in list (no element in this place, so go on to the next element in the list)
+===========================================================================================
+*/
+void FirstNode::get() {
+    next->get();
+}
+
+/*
+=======================
+insert end node in list
+=======================
+*/
+Node* EndNode::insert(LPoly* d) {
+    GenNode* data = new GenNode(d,this);
+    return data;
+}
+
+/*
+===============================================================================
+get end node in list (nothing to do, as there are no more elements in the list)
+===============================================================================
+*/
+void EndNode::get() {
+}
+
+/*
+=========================
+insert an element in list
+=========================
+*/
+void LpList::insert(LPoly* d) {
+   start->insert(d);
+   // there is no return value also we get the address of the new element in the list
+   // returning this value in the other insert functions is due to their virtual 
+   // declaration in the base class Node
+}
+
+/*
+==============================
+get all elements from the list 
+==============================
+*/
+void LpList::get() {
+    start->get();
+}
+
+#endif
Index: kernel/old/old.lplist.h
===================================================================
--- kernel/old/old.lplist.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.lplist.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,131 @@
+/****************************************
+*  Computer Algebra System SINGULAR     *
+****************************************/
+/*
+* ABSTRACT: list interface
+*/
+#include <kernel/lpolynomial.h>
+#ifndef LPLIST_HEADER
+#define LPLIST_HEADER
+
+#ifdef HAVE_F5
+
+
+
+
+
+/*
+=======================
+=======================
+linked lists for LPolys
+=======================
+=======================
+*/
+
+
+
+
+
+
+
+/*
+=================
+classes in a list
+=================
+*/
+class Node;
+class FirstNode;
+class LastNode;
+class GenNode;
+class LpList;
+
+/*
+===================
+abstract Node class
+===================
+*/
+class Node {
+    public:
+        Node() {};
+        virtual         ~Node() {};
+        // the following two functions have to be redefined in FirstNode, LastNode, and GenNode
+        virtual Node*   insert(LPoly* lp) = 0;
+        virtual void    get() = 0;
+};
+
+/*
+========================
+subclass GenNode of Node
+========================
+*/
+class GenNode : public Node {
+    private:
+        LPoly*  data;
+        Node*   next;
+    public:
+        GenNode(LPoly* d, Node* n) : data(d), next(n){};
+        ~GenNode() {
+            delete next;
+            delete data;
+        }
+        Node* insert(LPoly* d);
+        void get();
+};
+
+
+/*
+========================
+subclass EndNode of Node
+========================
+*/
+class EndNode : public Node {
+    public:
+        EndNode() {};
+        ~EndNode() {};
+        Node* insert(LPoly* d);
+        void get();
+};
+
+
+/*
+==========================
+subclass FirstNode of Node
+==========================
+*/
+class FirstNode : public Node {
+    private:
+        Node* next;
+    public:
+        FirstNode() {
+            next = new EndNode;
+        }
+        ~FirstNode() {};
+        Node* insert(LPoly* d);
+        void get();
+};
+
+
+/*
+============
+class LpList
+============
+*/
+class LpList {
+    private:
+        FirstNode *start;
+    public:
+        LpList() {
+            start = new FirstNode;
+        }
+        ~LpList() {
+            delete start;
+        }
+        void insert(LPoly* d);
+        void get();
+};
+
+
+
+#endif
+#endif
+
Index: kernel/old/old.si_gmp.h
===================================================================
--- kernel/old/old.si_gmp.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.si_gmp.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,18 @@
+
+#ifndef INCL_CF_GMP_H
+#define INCL_CF_GMP_H
+#ifdef HAVE_FACTORY
+#  include <factory/cf_gmp.h>
+#else
+#if defined(__cplusplus) && defined(__GNUC__)
+extern "C" {
+#undef __cplusplus
+#include <gmp.h>
+}
+#define __cplusplus 1
+#else
+#include <gmp.h>
+#endif
+
+#endif
+#endif /* ! INCL_CF_GMP_H */
Index: kernel/old/old.testpoly.cc
===================================================================
--- kernel/old/old.testpoly.cc	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.testpoly.cc	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,35 @@
+#include <kernel/Poly.h>
+
+void testPoly(){
+  Poly p(1,currRing);
+  Poly p2(2,currRing);
+  p.print();
+  p2.print();
+  (p+p2).print();
+  p2.print();
+  (p+=p).print();
+  p2.print();
+  std::vector<int> exp(3);
+  exp[0]=1;
+  Poly p3(exp,currRing);
+  exp[1]=2;
+  Poly p4(exp,currRing);
+  Poly p5=p;
+  Poly p6=(p+p2+p3+p4+p5);
+  PolyInputIterator<Poly> it=p6.begin();
+  p6.print();
+  while(it!=p6.end()){
+
+    it->print();
+
+    it++;
+  }
+
+  p4*=p4;
+  p4.print();
+  p2=p*p4;
+  p2.print();
+  p.print();
+  p4.print();
+  
+}
Index: kernel/old/old.testpoly.h
===================================================================
--- kernel/old/old.testpoly.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
+++ kernel/old/old.testpoly.h	(revision 1f93cdd20fd8f32e14a6b03e38d84fbc4311d0e0)
@@ -0,0 +1,1 @@
+void testPoly();
