diff --git a/include/curves/piecewise_curve.h b/include/curves/piecewise_curve.h
index 6d099e2c3f19fee10076ae0b649fbc655c61df0c..c5aa63c51185da965df4b428ed838218ec7c8bdc 100644
--- a/include/curves/piecewise_curve.h
+++ b/include/curves/piecewise_curve.h
@@ -236,7 +236,7 @@ namespace curves
       }
 
       template<typename Polynomial>
-      static piecewise_curve<Time, Numeric, Dim, Safe, Point, T_Point, Polynomial>
+      static piecewise_curve<Time, Numeric, Safe, Point, T_Point, Polynomial>
       convert_discrete_points_to_polynomial(T_Point points,T_Point points_derivative, t_time_t time_points)
       {
         if(Safe &! (points.size()>1))
@@ -250,7 +250,7 @@ namespace curves
         if(points.size() != points_derivative.size()){
             throw std::invalid_argument("piecewise_curve::convert_discrete_points_to_polynomial: Error, points and points_derivative must have the same size.");
         }
-        piecewise_curve<Time, Numeric, Dim, Safe, Point, T_Point, Polynomial> piecewise_res;
+        piecewise_curve<Time, Numeric, Safe, Point, T_Point, Polynomial> piecewise_res;
 
         for(size_t i = 1 ; i < points.size() ; ++i){
           piecewise_res.add_curve(Polynomial(points[i-1],points_derivative[i-1],points[i],points_derivative[i],time_points[i-1],time_points[i]));
@@ -259,7 +259,7 @@ namespace curves
       }
 
       template<typename Polynomial>
-      static piecewise_curve<Time, Numeric, Dim, Safe, Point, T_Point, Polynomial>
+      static piecewise_curve<Time, Numeric, Safe, Point, T_Point, Polynomial>
       convert_discrete_points_to_polynomial(T_Point points,T_Point points_derivative, T_Point points_second_derivative, t_time_t time_points)
       {
         if(Safe &! (points.size()>1))
@@ -276,7 +276,7 @@ namespace curves
         if(points.size() != points_second_derivative.size()){
             throw std::invalid_argument("piecewise_curve::convert_discrete_points_to_polynomial: Error, points and points_second_derivative must have the same size.");
         }
-        piecewise_curve<Time, Numeric, Dim, Safe, Point, T_Point, Polynomial> piecewise_res;
+        piecewise_curve<Time, Numeric, Safe, Point, T_Point, Polynomial> piecewise_res;
 
         for(size_t i = 1 ; i < points.size() ; ++i){
             piecewise_res.add_curve(Polynomial(points[i-1],points_derivative[i-1],points_second_derivative[i-1],points[i],points_derivative[i],points_second_derivative[i],time_points[i-1],time_points[i]));
diff --git a/include/curves/polynomial.h b/include/curves/polynomial.h
index a1f4540295f506eaca4fb7ac325b5a0e8b3b4179..bde952823b140b9322d8ced28efb75cfa8e4ec3a 100644
--- a/include/curves/polynomial.h
+++ b/include/curves/polynomial.h
@@ -84,6 +84,7 @@ namespace curves
         safe_check();
       }
 
+
       /// \brief Constructor.
       /// \param zeroOrderCoefficient : an iterator pointing to the first element of a structure containing the coefficients
       ///  it corresponds to the zero degree coefficient.
@@ -109,9 +110,11 @@ namespace curves
       /// \param max   : UPPER bound on interval definition of the spline.
       ///
       polynomial(const Point& init, const Point& end, const time_t min, const time_t max ):
-        dim_(Dim), degree_(1),
+        dim_(init.size()), degree_(1),
         T_min_(min), T_max_(max)
       {
+        if(init.size() != end.size())
+          throw std::invalid_argument("init and end points must have the same dimensions.");
         t_point_t coeffs;
         coeffs.push_back(init);
         coeffs.push_back((end-init)/(max-min));
@@ -130,9 +133,15 @@ namespace curves
       /// \param max   : UPPER bound on interval definition of the spline.
       ///
       polynomial(const Point& init,const Point& d_init, const Point& end, const Point& d_end,const time_t min, const time_t max ):
-        dim_(Dim), degree_(3),
+        dim_(init.size()), degree_(3),
         T_min_(min), T_max_(max)
       {
+        if(init.size() != end.size())
+          throw std::invalid_argument("init and end points must have the same dimensions.");
+        if(init.size() != d_init.size())
+          throw std::invalid_argument("init and d_init points must have the same dimensions.");
+        if(init.size() != d_end.size())
+          throw std::invalid_argument("init and d_end points must have the same dimensions.");
         /* the coefficients [c0 c1 c2 c3] are found by solving the following system of equation
         (found from the boundary conditions) :
         [1  0  0   0   ]   [c0]   [ init ]
@@ -172,9 +181,19 @@ namespace curves
       /// \param max   : UPPER bound on interval definition of the spline.
       ///
       polynomial(const Point& init,const Point& d_init,const Point& dd_init, const Point& end, const Point& d_end,const Point& dd_end,const time_t min, const time_t max ):
-        dim_(Dim), degree_(5),
+        dim_(init.size()), degree_(5),
         T_min_(min), T_max_(max)
       {
+        if(init.size() != end.size())
+          throw std::invalid_argument("init and end points must have the same dimensions.");
+        if(init.size() != d_init.size())
+          throw std::invalid_argument("init and d_init points must have the same dimensions.");
+        if(init.size() != d_end.size())
+          throw std::invalid_argument("init and d_end points must have the same dimensions.");
+        if(init.size() != dd_init.size())
+          throw std::invalid_argument("init and dd_init points must have the same dimensions.");
+        if(init.size() != dd_end.size())
+          throw std::invalid_argument("init and dd_end points must have the same dimensions.");
         /* the coefficients [c0 c1 c2 c3 c4 c5] are found by solving the following system of equation
         (found from the boundary conditions) :
         [1  0  0   0    0     0    ]   [c0]   [ init  ]