diff --git a/extensions/ExtendedProblemStat.h b/extensions/ExtendedProblemStat.h
index 9184673cc019e8265f7ad9e36a69838a36840fcc..10a4c9219fa48d3f93f6861f44d8c1fe9b20d1d9 100644
--- a/extensions/ExtendedProblemStat.h
+++ b/extensions/ExtendedProblemStat.h
@@ -243,8 +243,8 @@ protected:
     bool value1set = false;
 
     if (asmMatrix) {
-      typedef traits::range_generator<tag::row, Matrix>::type c_type;
-      typedef traits::range_generator<tag::nz, c_type>::type  ic_type;
+      typedef mtl::traits::range_generator<tag::row, Matrix>::type c_type;
+      typedef mtl::traits::range_generator<tag::nz, c_type>::type  ic_type;
 
       for (size_t col = 0; col < getNumComponents(); col++) {
 	TEST_EXIT(getSystemMatrix(row_, col) != NULL || col != col_)
@@ -255,9 +255,9 @@ protected:
 	// set Dirichlet-row in matrix
 	Matrix &m = getSystemMatrix(row_, col)->getBaseMatrix();
 
-	traits::row<Matrix>::type r(m);
-	traits::col<Matrix>::type c(m);
-	traits::value<Matrix>::type v(m);
+	mtl::traits::row<Matrix>::type r(m);
+	mtl::traits::col<Matrix>::type c(m);
+	mtl::traits::value<Matrix>::type v(m);
 
 	c_type cursor(begin<tag::row>(m)+idx_);
 	for (ic_type icursor(begin<tag::nz>(cursor)), icend(end<tag::nz>(cursor)); icursor != icend; ++icursor) {
@@ -287,8 +287,8 @@ protected:
     using namespace mtl;
     typedef DOFMatrix::base_matrix_type Matrix;
 
-    typedef traits::range_generator<tag::row, Matrix>::type c_type;
-    typedef traits::range_generator<tag::nz, c_type>::type  ic_type;
+    typedef mtl::traits::range_generator<tag::row, Matrix>::type c_type;
+    typedef mtl::traits::range_generator<tag::nz, c_type>::type  ic_type;
 
     for (size_t col = 0; col < getNumComponents(); col++) {
       TEST_EXIT(getSystemMatrix(row, col) != NULL)
@@ -296,9 +296,9 @@ protected:
 
       Matrix &m = getSystemMatrix(row, col)->getBaseMatrix();
 
-      traits::row<Matrix>::type r(m);
-      traits::col<Matrix>::type c(m);
-      traits::value<Matrix>::type v(m);
+      mtl::traits::row<Matrix>::type r(m);
+      mtl::traits::col<Matrix>::type c(m);
+      mtl::traits::value<Matrix>::type v(m);
       
       std::vector<std::vector<std::pair<DegreeOfFreedom, double> > > row_values;
       row_values.resize(indices.size());
@@ -349,8 +349,8 @@ protected:
     using namespace mtl;
     typedef DOFMatrix::base_matrix_type Matrix;
 
-    typedef traits::range_generator<tag::row, Matrix>::type c_type;
-    typedef traits::range_generator<tag::nz, c_type>::type  ic_type;
+    typedef mtl::traits::range_generator<tag::row, Matrix>::type c_type;
+    typedef mtl::traits::range_generator<tag::nz, c_type>::type  ic_type;
 
     TEST_EXIT(row_idx.size() == coefficients.size() && row_idx.size() == rhs.size() && rhs.size()>0)
       ("rhs_idx, coefficients and rhs must have the same size and size >! 0\n");
@@ -363,9 +363,9 @@ protected:
 
       Matrix &m = getSystemMatrix(row, col)->getBaseMatrix();
 
-      traits::row<Matrix>::type r(m);
-      traits::col<Matrix>::type c(m);
-      traits::value<Matrix>::type v(m);
+      mtl::traits::row<Matrix>::type r(m);
+      mtl::traits::col<Matrix>::type c(m);
+      mtl::traits::value<Matrix>::type v(m);
 
       // erase the rows for all row-indices and set rhs values
       for (size_t i = 0; i < coefficients.size(); i++) {
diff --git a/extensions/SignedDistFunctors.h b/extensions/SignedDistFunctors.h
index 821e83f3571c66a8dee716f58f655a8ded84775d..552d7fa13bcc0ffb1c504ed59992a66b06012e59 100644
--- a/extensions/SignedDistFunctors.h
+++ b/extensions/SignedDistFunctors.h
@@ -9,7 +9,6 @@
 
 using namespace std;
 using namespace AMDiS; 
-using namespace vector_operations;
 
 /**
  * A collection of signed-dist function describing several gemoetric objects:
@@ -33,6 +32,8 @@ static double signedDist2D(const WorldVector<double> x, const WorldVector<double
 			     AbstractFunction<double, double> *radius, double eps)
 {
   FUNCNAME("signedDist2D");
+  using vector_operations::epsNorm;
+  
   WorldVector<double> x_trans;
   double norm_xy;
   double alpha;
@@ -59,6 +60,8 @@ static double signedDist3D(const WorldVector<double> x, const WorldVector<double
 			     BinaryAbstractFunction<double, double, double> *radius, double eps)
 {
   FUNCNAME("signedDist3D");
+  using vector_operations::epsNorm;
+  
   WorldVector<double> x_trans;
   double norm_xyz, norm_xy;
   double alpha, beta;
diff --git a/extensions/ValueTypes.h b/extensions/ValueTypes.h
new file mode 100644
index 0000000000000000000000000000000000000000..e4156756ae02517a627b2699b498560633dadb11
--- /dev/null
+++ b/extensions/ValueTypes.h
@@ -0,0 +1,47 @@
+/** \file ValueTypes.h */
+
+#ifndef VALUE_TYPES_H
+#define VALUE_TYPES_H
+
+#include "AMDiS.h"
+#include "boost/type_traits.hpp"
+
+using namespace AMDiS;
+
+template<typename T> struct DOFView; 
+
+/// Type-Traits for value_type of Data-Structures
+/// ________________________________________________________________________________________________
+
+template<typename T, typename enable=void> struct ValueType { typedef T type; };
+template<typename T> struct ValueType<DOFVector<T> > { typedef T type; };
+template<typename T> struct ValueType<std::vector<T> > { typedef T type; };
+template<typename T> struct ValueType<std::list<T> > { typedef T type; };
+template<typename T> struct ValueType<std::set<T> > { typedef T type; };
+template<typename T> struct ValueType<mtl::dense_vector<T> > { typedef T type; };
+template<typename Derived> struct ValueType<Derived, typename boost::enable_if<boost::is_base_of<DOFView<double>, Derived > >::type> { typedef double type; };
+template<typename Derived> struct ValueType<Derived, typename boost::enable_if<boost::is_base_of<DOFView<WorldVector<double> >, Derived > >::type> { typedef WorldVector<double> type; };
+template<typename Derived> struct ValueType<Derived, typename boost::enable_if<boost::is_base_of<AbstractFunction<double, WorldVector<double> >, Derived > >::type> { typedef double type; };
+template<typename Derived> struct ValueType<Derived, typename boost::enable_if<boost::is_base_of<AbstractFunction<WorldVector<double>, WorldVector<double> >, Derived > >::type> { typedef WorldVector<double> type; };
+  
+
+/// random-accessible vectors
+/// ________________________________________________________________________________________________
+
+template<typename Vector> struct is_vector : public boost::false_type {};
+template<typename T> struct is_vector< std::vector<T> > : public boost::true_type {};
+template<typename T> struct is_vector< mtl::dense_vector<T> > : public boost::true_type {};
+template<typename T> struct is_vector< WorldVector<T> > : public boost::true_type {};
+
+/// random-accessible matrices
+/// ________________________________________________________________________________________________
+
+template<typename Matrix> struct is_matrix : public boost::false_type {};
+template<typename T, typename Param> struct is_matrix< mtl::matrix::base_matrix<T, Param> > : public boost::true_type {};
+template<typename T> struct is_matrix< mtl::matrix::dense2D<T> > : public boost::true_type {};
+template<typename T> struct is_matrix< mtl::matrix::compressed2D<T> > : public boost::true_type {};
+template<typename T> struct is_matrix< WorldMatrix<T> > : public boost::true_type {};
+
+
+
+#endif // VALUE_TYPES_H
diff --git a/extensions/VectorOperations.h b/extensions/VectorOperations.h
index b1a02aaf9ceec23f67fc63fb7ed2d4b84c646fea..87e771505ae8078dea8de3208161ccf486634e92 100644
--- a/extensions/VectorOperations.h
+++ b/extensions/VectorOperations.h
@@ -4,6 +4,7 @@
 #define VECTOR_OPERATIONS_H
 
 #include "AMDiS.h"
+#include "ValueTypes.h"
 
 #if HAVE_PARALLEL_DOMAIN_AMDIS
 #include "parallel/StdMpi.h"
@@ -16,6 +17,7 @@
 #include <string>
 #include <boost/numeric/mtl/mtl.hpp>
 #include <boost/numeric/itl/itl.hpp>
+#include <boost/utility/enable_if.hpp>
 
 using namespace AMDiS; 
 
@@ -76,67 +78,176 @@ public:
 
 namespace vector_operations {
 
-  // num_rows for vector types
-  template<typename T>
-  size_t num_rows(WorldVector<T> &v) {
-    return static_cast<size_t>(v.getSize());
-  };
-  template<typename T>
-  size_t num_rows(const WorldVector<T> &v) {
-    return static_cast<size_t>(v.getSize());
-  };
-  template<typename T>
-  size_t num_rows(std::vector<T> &v) {
-    return static_cast<size_t>(v.size());
-  };
-  template<typename T>
-  size_t num_rows(const std::vector<T> &v) {
-    return static_cast<size_t>(v.size());
-  };
-  template<typename T>
-  size_t num_rows(T &v) {
-    return 1;
-  };
-  template<typename T>
-  size_t num_rows(const T &v) {
-    return 1;
-  };
+  namespace traits {
 
-  // num_rows/num_cols for matrix types
-  template<typename T>
-  size_t num_rows(WorldMatrix<T> &m) {
-    return static_cast<size_t>(m.getNumRows());
-  };
-  template<typename T>
-  size_t num_rows(const WorldMatrix<T> &m) {
-    return static_cast<size_t>(m.getNumRows());
-  };
-  template<typename T>
-  size_t num_cols(WorldMatrix<T> &m) {
-    return static_cast<size_t>(m.getNumCols());
-  };
-  template<typename T>
-  size_t num_cols(const WorldMatrix<T> &m) {
-    return static_cast<size_t>(m.getNumCols());
-  };
-  
-  // common interface to resize vectors
-  template<typename T>
-  void resize(WorldVector<T> &v, size_t dim) {
-    TEST_EXIT(dim==v.getSize())("WorldVectors can not be resized to the given dimension!\n");
-  };
-  template<typename T>
-  void resize(std::vector<T> &v, size_t dim) {
-    v.resize(dim);
-  };
-  template<typename T>
-  void resize(mtl::dense_vector<T> &v, size_t dim) {
-    v.change_dim(dim);
-  };
+    /// General declaration, used to disable unsupported types
+    template <typename Collection, class Enable = void>
+    struct num_rows {};
+    
+    /// size implementation for STL vectors
+    template <typename Value>
+    struct num_rows< std::vector<Value> > 
+    {
+      typedef std::size_t   type;
+      type operator()(const std::vector<Value>& v) { return v.size(); }
+    };
+
+    /// size implementation for (1D) arrays interpreted as vectors
+    template <typename Value, unsigned Size>
+    struct num_rows<Value[Size]>
+    {
+      typedef std::size_t   type;
+      type operator()(const Value[Size]) { return Size; }
+    };	   
+
+    /// size implementation for (2D and higher) arrays interpreted as matrices
+    template <typename Value, unsigned Rows, unsigned Cols>
+    struct num_rows<Value[Rows][Cols]>
+    {
+      typedef std::size_t   type;
+      type operator()(const Value[Rows][Cols]) { return Rows; }
+    };	    
+    
+    template <typename Value>
+    struct num_rows< WorldVector<Value> > 
+    {
+      typedef std::size_t   type;
+      type operator()(const WorldVector<Value>& v) { return static_cast<size_t>(v.getSize()); }
+    };     
+    
+    template <typename Value>
+    struct num_rows< WorldMatrix<Value> > 
+    {
+      typedef std::size_t   type;
+      type operator()(const WorldMatrix<Value>& v) { return static_cast<size_t>(v.getNumRows()); }
+    };   
+    
+    template <typename Value>
+    struct num_rows< Value, typename boost::enable_if< boost::is_arithmetic<Value> >::type > 
+    {
+      typedef std::size_t   type;
+      type operator()(const Value& v) { return 1; }
+    };
+    
+    //________________________________________________________________________________    
+    
+    /// General declaration, used to disable unsupported types
+    template <typename Collection, class Enable = void>
+    struct num_cols {};
+    
+    template <typename Value>
+    struct num_cols< WorldMatrix<Value> > 
+    {
+      typedef std::size_t   type;
+      type operator()(const WorldMatrix<Value>& v) { return static_cast<size_t>(v.getNumCols()); }
+    };   
+    
+    //________________________________________________________________________________    
+    
+    /// General declaration, used to disable unsupported types
+    template <typename Collection, class Enable = void>
+    struct resize {};
+    
+    template <typename Value>
+    struct resize< WorldVector<Value> > 
+    {
+      typedef void   vector_void_type;
+      void operator()(WorldVector<Value>& v, size_t r) { 
+	TEST_EXIT(Global::getGeo(WORLD) == r)
+	  ("WorldVectors can not be resized!\n");
+      }
+    };   
+    
+    template <typename Value>
+    struct resize< std::vector<Value> > 
+    {
+      typedef void   vector_void_type;
+      void operator()(std::vector<Value>& v, size_t r) { 
+	v.resize(r);
+      }
+    };   
+    
+    template <typename Value>
+    struct resize< mtl::dense_vector<Value> > 
+    {
+      typedef void   vector_void_type;
+      void operator()(mtl::dense_vector<Value>& v, size_t r) { 
+	v.change_dim(r);
+      }
+    };
+        
+    // _________________________________________________________________________________
+        
+    template <typename Value>
+    struct resize< WorldMatrix<Value> > 
+    {
+      typedef void   matrix_void_type;
+      void operator()(WorldMatrix<Value>& v, size_t r, size_t c) { 
+	TEST_EXIT(Global::getGeo(WORLD) == r && Global::getGeo(WORLD) == c)
+	  ("WorldMatrices can not be resized!\n");
+      }
+    };   
+    
+    template <typename Value, typename Param>
+    struct resize< mtl::matrix::base_matrix<Value, Param> > 
+    {
+      typedef void   matrix_void_type;
+      void operator()(mtl::matrix::base_matrix<Value, Param>& v, size_t r, size_t c) { 
+	v.change_dim(r,c);
+      }
+    };
+    
+    template <typename Value>
+    struct resize< mtl::matrix::dense2D<Value> > 
+    {
+      typedef void   matrix_void_type;
+      void operator()(mtl::matrix::dense2D<Value>& v, size_t r, size_t c) { 
+	v.change_dim(r,c);
+      }
+    };
+    
+    template <typename Value>
+    struct resize< mtl::matrix::compressed2D<Value> > 
+    {
+      typedef void   matrix_void_type;
+      void operator()(mtl::matrix::compressed2D<Value>& v, size_t r, size_t c) { 
+	v.change_dim(r,c);
+      }
+    };
+  }
+
+  /// num_rows function for non-MTL types (uses implicit enable_if)
+  template <typename Collection>
+  typename traits::num_rows<Collection>::type 
+  inline num_rows(const Collection& c)
+  {  
+    return traits::num_rows<Collection>()(c);
+  }
   
+  /// num_cols function for non-MTL types (uses implicit enable_if)
+  template <typename Collection>
+  typename traits::num_cols<Collection>::type 
+  inline num_cols(const Collection& c)
+  {  
+    return traits::num_cols<Collection>()(c);
+  }
   
+  /// resize function for vectors
+  template <typename Collection>
+  typename traits::num_cols<Collection>::vector_void_type 
+  inline resize(const Collection& c, size_t rows)
+  {  
+    traits::resize<Collection>()(c, rows);
+  }
   
-  // B(phi)=phi^2*(1-phi)^2
+  /// resize function for matrices
+  template <typename Collection>
+  typename traits::num_cols<Collection>::matrix_void_type 
+  inline resize(const Collection& c, size_t rows, size_t cols)
+  {  
+    traits::resize<Collection>()(c, rows, cols);
+  }
+    
   template<typename T>
   T norm(mtl::dense_vector<T> &b) { return two_norm(b); };
   
@@ -185,16 +296,18 @@ namespace vector_operations {
   };
 
   template<typename Matrix>
-  double trace(Matrix &M)
+  inline typename boost::enable_if< is_matrix<Matrix>, double >::type
+  trace(Matrix &M)
   {
-    TEST_EXIT(num_rows(M)==num_cols(M))("Matrix dimensions must be equal!\n");
+    TEST_EXIT(num_rows(M) == num_cols(M))
+      ("Matrix dimensions must be equal!\n");
     typename Matrix::value_type sum;
-    sum = 0.0;
+    nullify(sum);
     for (size_t i = 0; i < num_rows(M); ++i) {
       sum += M[i][i];
     }
     return static_cast<double>(sum);
-  };
+  }
   
   template<typename T>
   Vector<T> mult(const Vector<T>& v1, const Vector<T>& v2)
@@ -247,180 +360,137 @@ namespace vector_operations {
     return result;
   };
 
-  template<typename T>
-  void copy(std::vector<T> &v, WorldVector<T> &w)
+  // copy v -> w
+  template<typename Vector1, typename Vector2>
+  inline void copy(Vector1 &v, Vector2 &w)
   {
-    for(int i=0; i<std::min((int)v.size(),(int)w.getSize()); i++)
-	    w[i]=v[i];
-  };
+    for (size_t i = 0; i < std::min(num_rows(v), num_rows(w)); i++)
+      w[i] = v[i];
+  }
   
-  template<typename T>
-  void copy(mtl::dense_vector<T> &v, WorldVector<T> &w)
+  // v3:=[v1, v2]
+  template<typename Vector1, typename Vector2, typename VectorOut>
+  inline void merge(Vector1 &v1, Vector2 &v2, VectorOut &v3)
   {
-    for(int i=0; i<std::min((int)num_rows(v),(int)w.getSize()); i++)
-	    w[i]=v[i];
-  };
-  
-  template<typename T>
-  void copy(WorldVector<T> &w, mtl::dense_vector<T> &v)
-  {
-    for(int i=0; i<std::min((int)num_rows(v),(int)w.getSize()); i++)
-	    v[i]=w[i];
-  };
+    resize(v3, num_rows(v1) + num_rows(v2));
+    for (size_t i = 0; i < num_rows(v1); i++)
+      v3[i] = v1[i];
+    for (size_t j = 0; j < num_rows(v2); j++)
+      v3[j + num_rows(v1)] = v2[j];
+  }
   
-  template<typename T>
-  void merge(std::vector<T> &v1, std::vector<T> &v2, std::vector<T> &v3)
+  template<typename Vector>
+  inline void getMin(const Vector &v, typename ValueType<Vector>::type &minVal, size_t &minIdx)
   {
-    v3.resize(v1.size()+v2.size());
-    for(int i=0;i<v1.size();i++)
-	    v3[i]=v1[i];
-    for(int j=0;j<v2.size();j++)
-	    v3[j+v1.size()]=v2[j];
-  };
-  
-  template<typename T>
-  void getMin(mtl::dense_vector<T> &v, T &minVal, unsigned &minIdx)
-  {
-    if(num_rows(v)==0) {
-      minVal = numeric_limits<T>::infinity();
-    } else {
-      minVal=v[0]; minIdx=0;
-      for(unsigned i=1; i<num_rows(v); i++) {
-	if(v[i]<minVal) { minVal=v[i]; minIdx=i; }
+    typedef typename ValueType<Vector>::type T;
+    TEST_EXIT(num_rows(v) > 0)("getMin of empty vector!\n");
+    
+    minVal = v[0];
+    minIdx = 0;
+    for (size_t i = 1; i < num_rows(v); i++) {
+      if (v[i] < minVal) {
+	minVal = v[i];
+	minIdx = i;
       }
     }
-  };
+  }
   
-  template<typename T>
-  void getMin(std::vector<T> &v, T &minVal, size_t &minIdx)
+  template<typename Vector>
+  inline void getMax(const Vector &v, typename ValueType<Vector>::type &maxVal, size_t &maxIdx)
   {
-    if (v.size() == 0) {
-      minVal = numeric_limits<T>::infinity();
-    } else {
-      minVal = v[0];
-      minIdx = 0;
-      for(size_t i = 1; i < v.size(); i++) {
-	if (v[i] < minVal) { 
-	  minVal=v[i];
-	  minIdx=i;
-	}
+    typedef typename ValueType<Vector>::type T;
+    TEST_EXIT(num_rows(v) > 0)("getMax of empty vector!\n");
+    
+    maxVal = v[0];
+    maxIdx = 0;
+    for (size_t i = 1; i < num_rows(v); i++) {
+      if (v[i] > maxVal) {
+	maxVal = v[i];
+	maxIdx = i;
       }
     }
-  };
-  
-  template<typename T>
-  void getMax(mtl::dense_vector<T> &v, T &maxVal, unsigned &maxIdx)
+  }
+
+  template<typename Vector>
+  inline typename ValueType<Vector>::type
+  min(const Vector &vec)
   {
-    if(num_rows(v)==0) {
-      maxVal = -numeric_limits<T>::infinity();
-    } else {
-      maxVal=v[0]; maxIdx=0;
-      for(unsigned i=1; i<num_rows(v); i++) {
-	if(v[i]>maxVal) { maxVal=v[i]; maxIdx=i; }
-      }
-    }
-  };
+    typename ValueType<Vector>::type minVal;
+    size_t minIdx;
+    getMin(vec, minVal, minIdx);
+    return minVal;
+  }
 
-  template<typename T>
-  T max(const std::vector<T> &vec)
+  template<typename Vector>
+  inline typename ValueType<Vector>::type
+  max(const Vector &vec)
   {
-    double maxVal;
-    if(vec.size()==0) {
-      maxVal = -numeric_limits<T>::infinity();
-    } else {
-      maxVal=vec[0];
-      for(size_t i=1; i<vec.size(); i++) {
-	if(vec[i]>maxVal) { maxVal=vec[i]; }
-      }
-    }
+    typename ValueType<Vector>::type maxVal;
+    size_t maxIdx;
+    getMax(vec, maxVal, maxIdx);
     return maxVal;
-  };
-
-  template<typename T>
-  T min(const std::vector<T> &vec)
+  }
+  
+  template<typename Vector>
+  inline typename ValueType<Vector>::type
+  absmin(const Vector &v)
   {
-    double minVal;
-    if(vec.size()==0) {
-      minVal = numeric_limits<T>::infinity();
-    } else {
-      minVal=vec[0];
-      for(size_t i=1; i<vec.size(); i++) {
-	if(vec[i]<minVal) { minVal=vec[i]; }
+    typedef typename ValueType<Vector>::type T;
+    TEST_EXIT(num_rows(v) > 0)("absmin of empty vector!\n");
+    
+    T minVal = abs(v[0]);
+    for(size_t i = 1; i < num_rows(v); i++) {
+      if (std::abs(v[i]) < minVal) {
+	minVal = std::abs(v[i]);
       }
     }
     return minVal;
-  };
+  }
   
-  template<typename T>
-  T absmax(std::vector<T> &vec)
+  template<typename Vector>
+  inline typename ValueType<Vector>::type
+  absmax(const Vector &v)
   {
-    double maxVal;
-    if(vec.size()==0) {
-      maxVal = -numeric_limits<T>::infinity();
-    } else {
-      maxVal=abs(vec[0]);
-      for(size_t i=1; i<vec.size(); i++) {
-	if(abs(vec[i])>maxVal) { maxVal=abs(vec[i]); }
+    typedef typename ValueType<Vector>::type T;
+    TEST_EXIT(num_rows(v) > 0)("absmax of empty vector!\n");
+    
+    T maxVal = abs(v[0]);
+    for(size_t i = 1; i < num_rows(v); i++) {
+      if (std::abs(v[i]) > maxVal) {
+	maxVal = std::abs(v[i]);
       }
     }
     return maxVal;
-  };
+  }
   
-  template<typename T>
-  T sum(std::vector<T> &vec)
+  template<typename Vector>
+  inline typename ValueType<Vector>::type
+  sum(const Vector &v)
   {
-    unsigned N=vec.size();
-    T value = 0;
-    if(N>0) {
-      value = vec[0];
-      for(unsigned i=1; i<N; ++i) {
-	value += vec[i];
-      }
+    typedef typename ValueType<Vector>::type T;
+    size_t N = num_rows(v);
+    T value; nullify(value);
+    if (N > 0) {
+      value = v[0];
+      for (size_t i = 1; i < N; ++i)
+	value += v[i];
     }
     return value;
-  };
+  }
   
-  template<typename T>
-  void getMean(std::vector<T> &vec, T &meanValue)
+  template<typename Vector>
+  inline typename ValueType<Vector>::type
+  mean(const Vector &v)
   {
-    unsigned N=vec.size();
-    meanValue = sum(vec)/double(N);
-  };
+    double N = static_cast<double>(num_rows(v));
+    return sum(v) * (1.0 / N);
+  }
   
-//   template<typename Vector1, typename Vector2>
-//   struct VectorPair {
-//     typedef typename Vector1::size_type 	size_type;
-//     typedef typename Vector1::value_type 	T1;
-//     typedef typename Vector2::value_type 	T2;
-//     typedef typename Vector1::iterator 		iterator1;
-//     typedef typename Vector2::iterator 		iterator2;
-//     typedef typename std::pair<T1, T2>& 	reference;
-//     typedef typename const std::pair<T1, T2>& 	const_reference;
-//     
-//     typedef struct PairIterator : public iterator<random_access_iterator_tag> {
-//       PairIterator(iterator1& iter1_, iterator2& iter2_) : iter1(iter1_), iter2(iter2_) {}
-//       PairIterator(const PairIterator& piter) : iter1(piter.iter1), iter2(piter.iter2) {}
-//       PairIterator& operator++() {++iter1; ++iter2; return *this;}
-//       PairIterator& operator--() {--iter1; --iter2; return *this;}
-//       PairIterator& operator+(int n) {PairIterator tmp(*this); tmp.iter1+=n; tmp.iter2+=n; return tmp;}
-//       PairIterator& operator-(int n) {PairIterator tmp(*this); tmp.iter1-=n; tmp.iter2-=n; return tmp;}
-//       PairIterator& operator+=(int n) {iter1+=n; iter2+=n; return *this;}
-//       PairIterator& operator-=(int n) {iter1-=n; iter2-=n; return *this;}
-// //       PairIterator operator++(int) {PairIterator tmp(*this); operator++(); return tmp;} //?1
-//       bool operator==(const PairIterator& rhs) {return iter1 == rhs.iter1 && iter2 == rhs.iter2;}
-//       bool operator<(const PairIterator& rhs) {return iter1 < rhs.iter1 && iter2 < rhs.iter2;}
-//       bool operator>(const PairIterator& rhs) {return iter1 > rhs.iter1 && iter2 > rhs.iter2;}
-//       bool operator<=(const PairIterator& rhs) {return iter1 <= rhs.iter1 && iter2 <= rhs.iter2;}
-//       bool operator>=(const PairIterator& rhs) {return iter1 >= rhs.iter1 && iter2 >= rhs.iter2;}
-//       bool operator!=(const PairIterator& rhs) {return iter1 != rhs.iter1 || iter2 != rhs.iter2;}
-//       std::pair<T1&, T2&>& operator*() {return std::make_pair(*iter1, *iter2);}
-//       std::pair<T1&, T2&>& operator[](int n) {return std::make_pair(*(iter1+n), *(iter2+n));}
-// 
-//     protected:
-//       iterator1 iter1;
-//       iterator2 iter2;
-//     } iterator;
-//   };
+  template<typename Vector>
+  void getMean(const Vector &v, typename ValueType<Vector>::type &meanValue)
+  {
+    meanValue = mean(v);
+  }
   
   template<typename T1, typename T2, typename Compare>
   void sort(std::vector<T1> &vec1, std::vector<T2> &vec2, Compare &comp)
diff --git a/extensions/Views.h b/extensions/Views.h
index bc17978974fd9b5db8be27d41e5c928eef92086f..54dc80865543429e963a6dc4662c7d7f82e359f2 100644
--- a/extensions/Views.h
+++ b/extensions/Views.h
@@ -8,6 +8,7 @@
 #include <boost/utility/enable_if.hpp>
 
 #include "AMDiS.h"
+#include "ValueTypes.h"
 #ifdef USE_BACKGROUNDMESH
   #include "BackgroundMesh.h"
 #endif
@@ -433,20 +434,6 @@ inline T evalAtPoint(AbstractFunction<T, WorldVector<double> > &obj, WorldVector
   return obj(p);
 };
 
-/// Type-Traits for value_type of Data-Structures
-/// ________________________________________________________________________________________________
-
-template<typename T, typename enable=void> struct ValueType { typedef T type; };
-template<typename T> struct ValueType<DOFVector<T> > { typedef T type; };
-template<typename T> struct ValueType<std::vector<T> > { typedef T type; };
-template<typename T> struct ValueType<std::list<T> > { typedef T type; };
-template<typename T> struct ValueType<std::set<T> > { typedef T type; };
-template<typename T> struct ValueType<mtl::dense_vector<T> > { typedef T type; };
-template<typename Derived> struct ValueType<Derived, typename boost::enable_if<boost::is_base_of<DOFView<double>, Derived > >::type> { typedef double type; };
-template<typename Derived> struct ValueType<Derived, typename boost::enable_if<boost::is_base_of<DOFView<WorldVector<double> >, Derived > >::type> { typedef WorldVector<double> type; };
-template<typename Derived> struct ValueType<Derived, typename boost::enable_if<boost::is_base_of<AbstractFunction<double, WorldVector<double> >, Derived > >::type> { typedef double type; };
-template<typename Derived> struct ValueType<Derived, typename boost::enable_if<boost::is_base_of<AbstractFunction<WorldVector<double>, WorldVector<double> >, Derived > >::type> { typedef WorldVector<double> type; };
-  
 /// transformDOF by coords (independent of mesh and feSpace)
 /// ________________________________________________________________________________________________