diff --git a/build_pdata.sh b/build_pdata.sh
index 858eec986da369d60297850fea8b5cc5adc2f628..8db1260f876aa66e07785e70556fcae067a9dd88 100644
--- a/build_pdata.sh
+++ b/build_pdata.sh
@@ -278,5 +278,5 @@ else
  fi
 fi
 
-curl -X POST --data "payload={\"icon_emoji\": \":jenkins:\", \"username\": \"jenkins\"  , \"attachments\":[{ \"title\":\"Info:\", \"color\": \"#00FF00\", \"text\":\"$MACHINE completed succeffuly the openfpm_pdata test \" }] }" https://hooks.slack.com/services/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
+curl -X POST --data "payload={\"icon_emoji\": \":jenkins:\", \"username\": \"jenkins\"  , \"attachments\":[{ \"title\":\"Info:\", \"color\": \"#00FF00\", \"text\":\"$2 completed succeffuly the openfpm_pdata test \" }] }" https://hooks.slack.com/services/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
 
diff --git a/example/Grid/0_simple/main.cpp b/example/Grid/0_simple/main.cpp
index d88ee12e007be5916f66d98f2ed60197acb72f5b..b725c8bf2d54aa72741d9166d66aace939f605d0 100644
--- a/example/Grid/0_simple/main.cpp
+++ b/example/Grid/0_simple/main.cpp
@@ -151,5 +151,5 @@ int main(int argc, char* argv[])
 	//
 	// Deinitialize the library
 	//
-	delete(global_v_cluster);
+	delete_global_v_cluster();
 }
diff --git a/example/Grid/1_stencil/main.cpp b/example/Grid/1_stencil/main.cpp
index 1a08184c6641c37d70b19b5a26893c7b45708ce1..3d4470c6cbc3606b3448cc56f781ee0477b410c6 100644
--- a/example/Grid/1_stencil/main.cpp
+++ b/example/Grid/1_stencil/main.cpp
@@ -154,5 +154,5 @@ int main(int argc, char* argv[])
 	//
 	// Deinitialize the library
 	//
-	delete(global_v_cluster);
+	delete_global_v_cluster();
 }
diff --git a/example/Vector/0_simple/main.cpp b/example/Vector/0_simple/main.cpp
index 17d0ddc1759ea06e019d9521ac0818a485c25d0b..8fb81a1c9f96ab275babd98bc622ea227372537a 100644
--- a/example/Vector/0_simple/main.cpp
+++ b/example/Vector/0_simple/main.cpp
@@ -118,9 +118,17 @@ int main(int argc, char* argv[])
 	v_cl.execute();
 	
 	//
-	// ### WIKI 14 ###
+	// ### WIKI 9 ###
+	//
+	// Output the particle position for each processor
+	//
+
+	vd.write("output");
+
+	//
+	// ### WIKI 10 ###
 	//
 	// Deinitialize the library
 	//
-	delete(global_v_cluster);
+	delete_global_v_cluster();
 }
diff --git a/install b/install
index 16bc51fe026c8290f88cb929491e4b2429482e15..fdd8c599897303bab53ce407d63d4c3b23fd3deb 100755
--- a/install
+++ b/install
@@ -161,7 +161,7 @@ else
 
         ## if MPI or METIS installation required install it
         if [ $conf_err -eq 200  ]; then
-            echo "MPI not found try to install"
+            echo "MPI not found try to install, $MPI_installed"
             if [ $MPI_installed -eq 1 ]; then
                 echo "Error the installation of MPI failed"
                 exit 1
@@ -169,7 +169,7 @@ else
             ./script/install_MPI.sh $i_dir $compiler_opt
             MPI_installed=1
             export PATH="$PATH:$i_dir/MPI/bin"
-
+            configure_options="$configure_options CXX=mpic++ "
         elif [ $conf_err -eq 201  ]; then
             echo "Metis not found try to install"
             if [ $METIS_installed -eq 1  ]; then
@@ -197,8 +197,8 @@ fi
 
 ### Create example.mk
 install_base=$(cat install_dir)
-echo "INCLUDE_PATH=-I. -I$install_base/openfpm_pdata/include/config -I$install_base/openfpm_pdata/include -I$install_base/openfpm_data/include -I$install_base/openfpm_vcluster/include -I$install_base/openfpm_io/include -I$install_base/openfpm_devices/include -I$i_dir/METIS/include" > example.mk
-echo "LIBS_PATH=-L$install_base/openfpm_devices/lib -L$install_base/openfpm_vcluster/lib -L$i_dir/METIS/lib " >> example.mk
+echo "INCLUDE_PATH=-I. -I$install_base/openfpm_pdata/include/config -I$install_base/openfpm_pdata/include -I$install_base/openfpm_data/include -I$install_base/openfpm_vcluster/include -I$install_base/openfpm_io/include -I$install_base/openfpm_devices/include -I$i_dir/METIS/include -I$i_dir/BOOST/include" > example.mk
+echo "LIBS_PATH=-L$install_base/openfpm_devices/lib -L$install_base/openfpm_vcluster/lib -L$i_dir/METIS/lib -L$i_dir/BOOST/lib " >> example.mk
 echo "LIBS=-lvcluster -lofpmmemory -lmetis -lboost_iostreams" >> example.mk
 cp example.mk src/example.mk
 cp example.mk example/example.mk
diff --git a/script/detect_gcc b/script/detect_gcc
new file mode 100755
index 0000000000000000000000000000000000000000..87b5e510a77b34ccd7128b26861b1591a92e4ed9
--- /dev/null
+++ b/script/detect_gcc
@@ -0,0 +1,115 @@
+#! /bin/bash
+
+function detect_gcc_or_clang()
+{
+    command -v $1 >/dev/null 2>&1
+    if [ $? -ne 0 ]; then
+      dgc_ret=0
+      return
+    fi
+
+    # First we try to understand if g++ command line is linked to clang
+    
+    $1 --version | grep "Apple LLVM"
+    if [ $? == 0 ]; then
+        echo "Apple LLVM based g++"
+
+        # we try the detect the version
+        major=$(g++ --version | grep LLVM | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*(.*/\1/g')
+
+        # we check if the detection is garbage
+        echo "$major" | egrep -q '^[0-9]+$'
+        if [ $? == 0 ]; then
+           dgc_major=$($1 --version | grep LLVM | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*(.*/\1/g')
+           dgc_middle=$($1 --version | grep LLVM | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*(.*/\2/g')
+           dgc_minor=$($1 --version | grep LLVM | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*(.*/\3/g')
+
+           if [ $dgc_major -gt 6 ]; then
+             echo -e "clang++ $dgc_major.$dgc_middle.$dgc_minor \033[92;1m SUCCESS \033[0m"
+             dgc_compiler=clang++
+             dgc_ret=1
+           elif [ $dgc_major -lt 6 ]; then
+             echo -e "clang++ $dgc_major.$dgc_middle.$dgc_minor \033[91;5;1m FAILED \033[0m your Apple clang $major.middle;$minor is too old, 6.1.0 or higher is required"
+             dgc_ret=0
+           elif [ $dgc_middle -gt 1  ]; then
+             echo -e "clang++ $dgc_major.$dgc_middle.$dgc_minor \033[92;1m SUCCESS \033[0m"
+             dgc_compiler=clang++
+             dgc_ret=1
+           elif [ $dgc_minor -lt 1 ]; then
+             echo -e "clang++ $dgc_major.$dgc_middle.$dgc_minor \033[91;5;1m FAILED \033[0m your Apple clang $major.middle;$minor is too old, 6.1.0 or higher is required"
+             dgc_ret=0
+           else
+             echo -e "Apple clang++ version $dgc_major.$dgc_middle.$dgc_minor \033[92;1m SUCCESS \033[0m"
+             dgc_compiler=clang++
+             dgc_ret=1
+           fi
+           return
+        fi
+        dgc_ret=2
+        return
+    fi
+
+    $1 --version | grep $1
+    if [ $? == 0 -a x"$1" == x"gcc" ]; then
+        dgc_major=$($1 --version | grep $1 | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
+        dgc_middle=$($1 --version | grep $1 | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2/g')
+        dgc_minor=$($1 --version | grep $1 | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\3/g')
+
+        if [ $dgc_major -gt 4 ]; then
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor \033[92;1m SUCCESS \033[0m"
+          dgc_compiler=g++
+          dgc_ret=1
+        elif [ $dgc_major -lt 4 ]; then
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor  \033[91;5;1m FAILED \033[0m your g++ version is too old, 4.8.2 at least required"
+          dgc_ret=0
+        elif [ $dgc_middle -gt 8  ]; then
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor \033[92;1m SUCCESS \033[0m"
+          dgc_compiler=g++
+          dgc_ret=1
+        elif [ $dgc_middle -lt 8 ]; then
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor \033[91;5;1m FAILED \033[0m your g++ version is too old, 4.8.2 at least required"
+          dgc_ret=0
+        elif [ $dgc_minor -gt 1  ]; then
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor \033[92;1m SUCCESS \033[0m"
+          dgc_compiler=g++
+          dgc_ret=1
+        else
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor \033[92;1m FAILED \033[0m your g++ version is too old, 4.8.2 at least required"
+          dgc_ret=0
+        fi
+        return
+    fi
+
+    $1 --version | grep $1
+    if [ $? == 0 -a x"$1" == x"clang" ]; then
+        dgc_major=$($1 --version | grep $1 | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
+        dgc_middle=$($1 --version | grep $1 | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2/g')
+        dgc_minor=$($1 --version | grep $1 | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\3/g')
+
+        if [ $dgc_major -gt 3 ]; then
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor \033[92;1m SUCCESS \033[0m"
+          dgc_compiler=clang++
+          dgc_ret=1
+        elif [ $dgc_major -lt 3 ]; then
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor  \033[91;5;1m FAILED \033[0m your clang version is too old 3.6.0 at least required"
+          dgc_ret=0
+        elif [ $dgc_middle -gt 6  ]; then
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor \033[92;1m SUCCESS \033[0m"
+          dgc_compiler=clang++
+          dgc_ret=1
+        elif [ $dgc_middle -lt 6 ]; then
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor \033[91;5;1m FAILED \033[0m your clang version is too old 3.6.0 at least required"
+          dgc_ret=0
+        else
+          echo -e "$1 $dgc_major.$dgc_middle.$dgc_minor \033[92;1m SUCCESS \033[0m"
+          dgc_compiler=clang++
+          dgc_ret=0
+        fi
+        return
+    fi
+
+
+    dgc_ret=0
+}
+
+
diff --git a/script/detect_osx b/script/detect_osx
new file mode 100755
index 0000000000000000000000000000000000000000..8dcba235c2b14f9230a17b7d9a1aab3abef485eb
--- /dev/null
+++ b/script/detect_osx
@@ -0,0 +1,50 @@
+#! /bin/bash
+
+function detect_osx()
+{
+    if [ x"$1" != x"osx" ]; then
+      return
+    fi
+
+    # Try first pattern
+
+    version=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
+    echo "$version" | egrep -q '^[0-9]+$'
+    if [ $? == 0 ]; then
+      dosx_major=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
+      dosx_middle=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2/g')
+      dosx_minor=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\3/g')
+
+      if [ $dosx_major -gt 10 ]; then
+        dosx_ret=1
+      elif [ $dosx_major -lt 10 ]; then
+        dosx_ret=0
+      elif [ $dosx_middle -gt 10  ]; then
+        dosx_ret=1
+      elif [ $dosx_middle -lt 10 ]; then
+        dosx_ret=1
+      else
+        dosx_ret=0
+       fi
+    fi
+
+    version=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\).*/\1/g')
+    echo "$version" | egrep -q '^[0-9]+$'
+    if [ $? == 0 ]; then
+      dosx_major=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\).*/\1/g')
+      dosx_middle=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\).*/\2/g')
+
+      if [ $dosx_major -gt 10 ]; then
+        dosx_ret=1
+      elif [ $dosx_major -lt 10 ]; then
+        dosx_ret=0
+      elif [ $dosx_middle -gt 10  ]; then
+        dosx_ret=1
+      elif [ $dosx_middle -lt 10 ]; then
+        dosx_ret=1
+      else
+        dosx_ret=0
+      fi
+    fi
+}
+
diff --git a/script/pre_req b/script/pre_req
index 226a31e705d365776eab7927386688ba9892c051..41d6f0cbcfce3aacb023e83f3da57c51c2352f47 100755
--- a/script/pre_req
+++ b/script/pre_req
@@ -12,6 +12,8 @@ source script/solve_wget
 source script/solve_automake
 source script/solve_brew
 source script/solve_libtool
+source script/detect_gcc
+source script/detect_osx
 
 discover_os
 discover_package_manager $platform
@@ -139,103 +141,19 @@ fi
 
 #### Detecting g++
 
-if [ x"$platform" == x"osx" ]; then
-  ## we try to detect osx version
-  major=$(g++ --version | grep LLVM | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)svn.*/\1/g')
-  middle=$(g++ --version | grep LLVM | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)svn.*/\2/g')
-  minor=$(g++ --version | grep LLVM | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)svn.*/\3/g')
-
-  echo "$major" | egrep -q '^[0-9]+$'
-  is_maj_num=$?
-  echo "$minor" | egrep -q '^[0-9]+$'
-  is_min_num=$?
-  echo "$middle" | egrep -q '^[0-9]+$'
-  is_mid_num=$?
-
-  command -v g++-4.9  >/dev/null 2>&1
-  opt1=$?
-
-  # Major middle and minor should contain only numbers, if they dont, and smaller than 2 character otherwise the detection was garbage
-  if [ $is_maj_num -ne 0 -o $is_min_num -ne 0 -o $is_mid_num -ne 0 ]; then
-    if [ $opt1 -eq 1 ]; then
-      ## the detection is garbage, gcc49 id not present, now we check the system
-
-      major=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
-      middle=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2/g')
-      minor=$(sw_vers | grep ProductVersion | sed 's/.*\([0-9][0-9]\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\3/g')
-
-      if [ $major -gt 10 ]; then
-        echo -e "\033[30;43;5;1m------------------------------- WARNING --------------------------------\033[0m"
-        echo "g++ seem to be present, but we failed to detect the version. Your system $major.$middle.$minor seem to be recent enough, so we will continue the installation"
-        sleep 10
-      elif [ $major -lt 10 ]; then
-        echo -e "\033[30;43;5;1m------------------------------- WARNING --------------------------------\033[0m"
-        echo "g++ seem to be present, but we failed to detect the version. Your system $major.$middle.$minor is older than 10.10.X, so is probably going to fail with the actual compiler"
-        echo "One possible solution is to try to install gcc 4.9"
-        solve_gpp $platform
-      elif [ $middle -gt 10 ]; then
-        echo -e "\033[30;43;5;1m------------------------------- WARNING --------------------------------\033[0m"
-        echo "g++ seem to be present, but we failed to detect the version. Your system $major.$middle.$minor seem to be recent enough, so we will continue the installation"
-        sleep 10       
-      elif [ $middle -lt 10 ]; then
-        echo -e "\033[30;43;5;1m------------------------------- WARNING --------------------------------\033[0m"
-        echo "g++ seem to be present, but we failed to detect the version. Your system $major.$middle.$minor is older than 10.10.X, so is probably going to fail with the actual compiler"
-        echo "One possible solution is to try to install gcc 4.9"
-        solve_gpp $platform
-      else
-        echo -e "\033[30;43;5;1m------------------------------- WARNING --------------------------------\033[0m"
-        echo "g++ seem to be present, but we failed to detect the version. Your system $major.$middle.$minor seem to be recent enough, so we will continue the installation"
-        sleep 10
-      fi
-    fi
-  else
-    ## the detection is good check the compiler
-
-    if [ $major -gt 3 ]; then
-      echo -e "clang++ $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
-    elif [ $major -lt 3 ]; then
-      echo -e "clang++ $major.$middle.$minor \033[91;5;1m FAILED \033[0m your clang $major.middle;$minor is too old, 3.6.0 or higher is required"
-      solve_gpp $platform
-    elif [ $middle -gt 6  ]; then
-      echo -e "clang++ $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
-    elif [ $middle -lt 6 ]; then
-      echo -e "clang++\033[91;5;1m FAILED \033[0m your clang is out of date, update to 3.6.0 or higher is required"
-      solve_gpp $platform
-    else
-      echo -e "clang++ version $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
-    fi
+detect_gcc_or_clang gcc
+if [ $dgc_ret -eq 0 ]; then
+  solve_gpp $platform
+  detect_gcc_or_clang gcc-4.9
+  if [ $dgc_ret -eq 0 ]; then
+    exit 1
   fi
-else
-  command -v g++ >/dev/null 2>&1
-  if [ $? -ne 0 ]; then
-    echo >&2
-    echo -e "Configure\033[91;5;1m FAILED \033[0m"
-    echo "OpenFPM require g++ but it's not installed, searching a solution..."
-    solve_gpp $platform
-    command -v g++ >/dev/null 2>&1
-    if [ $? -ne 0 ]; then
-      echo -e "g++\033[91;5;1m FAILED \033[0m"
-      exit 1
-    else
-      echo -e "g++\033[92;1m SUCCESS \033[0m"
-    fi
-  else
-    major=$(g++ --version | grep g++ | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1/g')
-    middle=$(g++ --version | grep g++ | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2/g')
-    minor=$(g++ --version | grep g++ | sed 's/.*\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\3/g')
-    if [ $major -gt 4 ]; then
-      echo -e "g++ $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
-    elif [ $major -lt 4 ]; then
-      echo -e "g++ $major.$middle.$minor  \033[91;5;1m FAILED \033[0m your g++ version is too old"
-    elif [ $middle -gt 8  ]; then
-      echo -e "g++ $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
-    elif [ $middle -lt 8 ]; then
-      echo -e "g++ $major.$middle.$minor \033[91;5;1m FAILED \033[0m your g++ version is too old"
-    elif [ $minor -gt 1  ]; then
-      echo -e "g++ $major.$middle.$minor \033[92;1m SUCCESS \033[0m"
-    else
-      echo -e "g++ $major.$middle.$minor \033[92;1m FAILED \033[0m your g++ version is too old"
-    fi
+elif [ $dgc_ret -eq 2 ]; then
+  detect_osx $platform
+  if [ $dosx_ret -eq 1 ]; then
+    echo -e "\033[30;43;5;1m------------------------------- WARNING --------------------------------\033[0m"
+    echo "g++ seem to be present, but we failed to detect the version. Your system $dosx_major.$dosx_middle.$dosx_minor seem to be recent enough, so we will continue the installation"
+    sleep 10    
   fi
 fi
 
diff --git a/script/py/pack_examples.py b/script/py/pack_examples.py
old mode 100644
new mode 100755
diff --git a/script/py/process_examples.py b/script/py/process_examples.py
old mode 100644
new mode 100755
diff --git a/src/Decomposition/CartDecomposition.hpp b/src/Decomposition/CartDecomposition.hpp
index ad48a26e5ee2d929892d750a74dc953dc5a0fea2..216c15e7b018c48c84878df69dd4291ec81dc6f8 100644
--- a/src/Decomposition/CartDecomposition.hpp
+++ b/src/Decomposition/CartDecomposition.hpp
@@ -334,15 +334,33 @@ private:
 	// Receive counter
 	size_t recv_cnt;
 
+	// reference counter of the object in case is shared between object
+
+	long int ref_cnt;
+
 public:
 
+	//! Increment the reference counter
+	void incRef()
+	{ref_cnt++;}
+
+	//! Decrement the reference counter
+	void decRef()
+	{ref_cnt--;}
+
+	//! Return the reference counter
+	long int ref()
+	{
+		return ref_cnt;
+	}
+
 	/*! \brief Cartesian decomposition constructor
 	 *
      * \param v_cl Virtual cluster, used internally to handle or pipeline communication
 	 *
 	 */
 	CartDecomposition(Vcluster & v_cl)
-	:nn_prcs<dim,T>(v_cl),v_cl(v_cl)
+	:nn_prcs<dim,T>(v_cl),v_cl(v_cl),ref_cnt(0)
 	{
 		// Reset the box to zero
 		bbox.zero();
diff --git a/src/Decomposition/DistModel.hpp b/src/Decomposition/DistModel.hpp
deleted file mode 100644
index 5980dc8ac8a4731ebfb689ea09c02e91e92e4fd8..0000000000000000000000000000000000000000
--- a/src/Decomposition/DistModel.hpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef DIST_MODEL_HPP
-#define DIST_MODEL_HPP
-
-#include "metis.h"
-
-/*! \brief This class do graph partitioning
- *
- * This class do graph partitioning, it use METIS internaly
- *
- */
-
-template<typename Graph, typename algorithm>
-class GraphPartitioning
-{
-	//! Structure that store the graph
-	Graph & grp;
-
-	/*! Constructor
-	 *
-	 * It load the graph to partition
-	 *
-	 * \param g Graph to store
-	 *
-	 */
-	GraphPartitioning(Graph & g)
-	:grp(g)
-	{}
-};
-
-#endif
diff --git a/src/Decomposition/ie_loc_ghost.hpp b/src/Decomposition/ie_loc_ghost.hpp
index e60791e6429760750c006930962bc3089689b61e..06f13c43b246a59f68f2c6d15a1d9e8db7f80901 100644
--- a/src/Decomposition/ie_loc_ghost.hpp
+++ b/src/Decomposition/ie_loc_ghost.hpp
@@ -131,7 +131,7 @@ public:
 	 *
 	 * \param id sub-domain id
 	 *
-	 * \return the number of internal ghost box
+	 * \return the number of external ghost box
 	 *
 	 */
 	inline size_t getLocalNEGhost(size_t id)
diff --git a/src/Grid/grid_dist_id.hpp b/src/Grid/grid_dist_id.hpp
index 6f685d8dbc81ed0c95df73570e4cea98378f0a19..77bf8f1dbec5650cdd86273bd2b6d506100f1ed6 100644
--- a/src/Grid/grid_dist_id.hpp
+++ b/src/Grid/grid_dist_id.hpp
@@ -40,8 +40,13 @@
  * \snippet grid_dist_id_unit_test.hpp Create and access a distributed grid complex
  * ### Synchronize a distributed grid for complex structures
  * \snippet grid_dist_id_unit_test.hpp Synchronized distributed grid complex
+<<<<<<< HEAD
  * ### Usage of a grid dist iterator sub
  * \snippet grid_dist_id_unit_test.hpp Usage of a sub_grid iterator
+=======
+ * ### Construct two grid with the same decomposition
+ * \snippet grid_dist_id_unit_test.hpp Construct two grid with the same decomposition
+>>>>>>> master
  *
  */
 template<unsigned int dim, typename St, typename T, typename Decomposition,typename Memory=HeapMemory , typename device_grid=grid_cpu<dim,T> >
@@ -57,7 +62,7 @@ class grid_dist_id
 	Vcluster_object_array<device_grid> loc_grid;
 
 	//! Space Decomposition
-	Decomposition dec;
+	Decomposition & dec;
 
 	//! Extension of each grid: Domain and ghost + domain
 	openfpm::vector<GBoxes<device_grid::dims>> gdb_ext;
@@ -356,6 +361,7 @@ class grid_dist_id
 		}
 	}
 
+<<<<<<< HEAD
 	/*! \brief Create the grids on memory
 	 *
 	 */
@@ -363,6 +369,18 @@ class grid_dist_id
 	{
 		Box<dim,St> g_rnd_box;
 		for (size_t i = 0 ; i < dim ; i++)	{g_rnd_box.setHigh(i,0.5); g_rnd_box.setLow(i,-0.5);}
+=======
+public:
+
+	//! constructor
+	grid_dist_id(Decomposition & dec, const size_t (& g_sz)[dim], const Box<dim,St> & domain, const Ghost<dim,St> & ghost)
+	:domain(domain),ghost(ghost),dec(dec),v_cl(*global_v_cluster)
+	{
+		// Increment the reference counter of the decomposition
+		dec.incRef();
+
+		check_size(g_sz);
+>>>>>>> master
 
 		// Get the number of local grid needed
 		size_t n_grid = dec.getNLocalHyperCube();
@@ -370,6 +388,7 @@ class grid_dist_id
 		// create local grids for each hyper-cube
 		loc_grid = v_cl.allocate<device_grid>(n_grid);
 
+<<<<<<< HEAD
 		// Size of the grid on each dimension
 		size_t l_res[dim];
 
@@ -385,10 +404,15 @@ class grid_dist_id
 			// Convert from SpaceBox<dim,St> to SpaceBox<dim,long int>
 			SpaceBox<dim,long int> sp_t = cd_sm.convertDomainSpaceIntoGridUnits(sp);
 			SpaceBox<dim,long int> sp_tg = cd_sm.convertDomainSpaceIntoGridUnits(sp_g);
+=======
+		// fill the global size of the grid
+		for (size_t i = 0 ; i < dim ; i++)	{this->g_sz[i] = g_sz[i];}
+>>>>>>> master
 
 			//! Save the origin of the sub-domain of the local grid
 			gdb_ext.last().origin = sp_tg.getP1();
 
+<<<<<<< HEAD
 			// save information about the local grid: domain box seen inside the domain + ghost box (see GDBoxes for a visual meaning)
 			// and where the GDBox start, or the origin of the local grid (+ghost) in global coordinate
 			gdb_ext.last().Dbox = sp_t;
@@ -403,6 +427,10 @@ class grid_dist_id
 			// Set the dimensions of the local grid
 			loc_grid.get(i).resize(l_res);
 		}
+=======
+		// Calculate ghost boxes
+		dec.calculateGhostBoxes();
+>>>>>>> master
 	}
 
 	/*! \brief Default Copy constructor on this class make no sense and is unsafe, this definition disable it
@@ -416,8 +444,16 @@ class grid_dist_id
 	 *
 	 *
 	 */
+<<<<<<< HEAD
 	inline void InitializeCellDecomposer(const size_t (& g_sz)[dim])
+=======
+	grid_dist_id(const size_t (& g_sz)[dim],const Box<dim,St> & domain, const Ghost<dim,St> & g)
+	:domain(domain),ghost(g),dec(*new Decomposition(*global_v_cluster)),v_cl(*global_v_cluster)
+>>>>>>> master
 	{
+		// Increment the reference counter of the decomposition
+		dec.incRef();
+
 		// check that the grid has valid size
 		check_size(g_sz);
 
@@ -640,6 +676,11 @@ public:
 	//! Destructor
 	~grid_dist_id()
 	{
+		dec.decRef();
+
+		// if we reach the 0, destroy the object
+		if (dec.ref() == 0)
+			delete &dec;
 	}
 
 	/*! \brief Get the Virtual Cluster machine
diff --git a/src/Grid/grid_dist_id_unit_test.hpp b/src/Grid/grid_dist_id_unit_test.hpp
index c7cdd63ce7f608c5bf0dfbe49578942817ef53e3..aed99d31ff0a46c87a8dd3024cc8a1b480c85310 100644
--- a/src/Grid/grid_dist_id_unit_test.hpp
+++ b/src/Grid/grid_dist_id_unit_test.hpp
@@ -872,24 +872,24 @@ void Test3D_complex(const Box<3,float> & domain, long int k)
 			// In this case the boundary condition are non periodic
 			if (g_dist.isInside(key_g))
 			{
-				match &= (g_dist.template get<p::x>(key),1 + k)?true:false;
-				match &= (g_dist.template get<p::y>(key),567 + k)?true:false;
-				match &= (g_dist.template get<p::z>(key), 341 + k)?true:false;
-				match &= (g_dist.template get<p::s>(key), 5670 + k)?true:false;
-
-				match &= (g_dist.template get<p::v>(key)[0], 921 + k)?true:false;
-				match &= (g_dist.template get<p::v>(key)[1], 5675 + k)?true:false;
-				match &= (g_dist.template get<p::v>(key)[2], 117 + k)?true:false;
-
-				match &= (g_dist.template get<p::t>(key)[0][0], 1921 + k)?true:false;
-				match &= (g_dist.template get<p::t>(key)[0][1], 25675 + k)?true:false;
-				match &= (g_dist.template get<p::t>(key)[0][2], 3117 + k)?true:false;
-				match &= (g_dist.template get<p::t>(key)[1][0], 4921 + k)?true:false;
-				match &= (g_dist.template get<p::t>(key)[1][1], 55675 + k)?true:false;
-				match &= (g_dist.template get<p::t>(key)[1][2], 6117 + k)?true:false;
-				match &= (g_dist.template get<p::t>(key)[2][0], 7921 + k)?true:false;
-				match &= (g_dist.template get<p::t>(key)[2][1], 85675 + k)?true:false;
-				match &= (g_dist.template get<p::t>(key)[2][2], 9117 + k)?true:false;
+				match &= (g_dist.template get<p::x>(key) == 1 + k)?true:false;
+				match &= (g_dist.template get<p::y>(key) == 567 + k)?true:false;
+				match &= (g_dist.template get<p::z>(key) == 341 + k)?true:false;
+				match &= (g_dist.template get<p::s>(key) == 5670 + k)?true:false;
+
+				match &= (g_dist.template get<p::v>(key)[0] == 921 + k)?true:false;
+				match &= (g_dist.template get<p::v>(key)[1] == 5675 + k)?true:false;
+				match &= (g_dist.template get<p::v>(key)[2] == 117 + k)?true:false;
+
+				match &= (g_dist.template get<p::t>(key)[0][0] == 1921 + k)?true:false;
+				match &= (g_dist.template get<p::t>(key)[0][1] == 25675 + k)?true:false;
+				match &= (g_dist.template get<p::t>(key)[0][2] == 3117 + k)?true:false;
+				match &= (g_dist.template get<p::t>(key)[1][0] == 4921 + k)?true:false;
+				match &= (g_dist.template get<p::t>(key)[1][1] == 55675 + k)?true:false;
+				match &= (g_dist.template get<p::t>(key)[1][2] == 6117 + k)?true:false;
+				match &= (g_dist.template get<p::t>(key)[2][0] == 7921 + k)?true:false;
+				match &= (g_dist.template get<p::t>(key)[2][1] == 85675 + k)?true:false;
+				match &= (g_dist.template get<p::t>(key)[2][2] == 9117 + k)?true:false;
 			}
 
 			++domg;
@@ -899,6 +899,106 @@ void Test3D_complex(const Box<3,float> & domain, long int k)
 	}
 }
 
+// Test duplicated topology
+
+void Test3D_dup(const Box<3,float> & domain, long int k)
+{
+	long int big_step = k / 30;
+	big_step = (big_step == 0)?1:big_step;
+	long int small_step = 1;
+
+	Vcluster & v_cl = *global_v_cluster;
+
+	if ( v_cl.getProcessingUnits() > 32 )
+		return;
+
+	print_test( "Testing 3D duplicate topology complex k<=",k);
+
+	// 3D test
+	for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
+	{
+		BOOST_TEST_CHECKPOINT( "Testing 3D copy decomposition grid k=" << k );
+
+		// grid size
+		size_t sz[3];
+		sz[0] = k;
+		sz[1] = k;
+		sz[2] = k;
+
+		// factor
+		float factor = pow(global_v_cluster->getProcessingUnits()/2.0f,1.0f/3.0f);
+
+		// Ghost
+		Ghost<3,float> g(0.01 / factor);
+
+		//! [Construct two grid with the same decomposition]
+
+		// Distributed grid with id decomposition
+		grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>> g_dist1(sz,domain,g);
+
+		// another grid with the same decomposition
+		grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>> g_dist2(g_dist1.getDecomposition(),sz,domain,g);
+
+		//! [Construct two grid with the same decomposition]
+
+		BOOST_REQUIRE_EQUAL(g_dist2.getDecomposition().ref(),2);
+
+		auto dom_g1 = g_dist1.getDomainIterator();
+		auto dom_g2 = g_dist2.getDomainIterator();
+
+		bool check = true;
+
+		while (dom_g1.isNext())
+		{
+			auto key1 = dom_g1.get();
+			auto key2 = dom_g2.get();
+
+			check &= (key1 == key2)?true:false;
+
+			++dom_g1;
+			++dom_g2;
+		}
+
+		BOOST_REQUIRE_EQUAL(check,true);
+	}
+
+	// 3D test
+	for ( ; k >= 2 ; k-= (k > 2*big_step)?big_step:small_step )
+	{
+		BOOST_TEST_CHECKPOINT( "Testing 3D copy decomposition grid k=" << k );
+
+		// grid size
+		size_t sz[3];
+		sz[0] = k;
+		sz[1] = k;
+		sz[2] = k;
+
+		// factor
+		float factor = pow(global_v_cluster->getProcessingUnits()/2.0f,1.0f/3.0f);
+
+		// Ghost
+		Ghost<3,float> g(0.01 / factor);
+
+		//! [Construct two grid with the same decomposition]
+
+		// Distributed grid with id decomposition
+		grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>> * g_dist1 = new grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>>(sz,domain,g);
+
+		// another grid with the same decomposition
+		grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>> * g_dist2 = new grid_dist_id<3, float, Point_test<float>, CartDecomposition<3,float>>(g_dist1->getDecomposition(),sz,domain,g);
+
+		//! [Construct two grid with the same decomposition]
+
+		BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().ref(),2);
+
+		delete g_dist1;
+
+		BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().ref(),1);
+		BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().getLocalNEGhost(0) != 0, true);
+		BOOST_REQUIRE_EQUAL(g_dist2->getDecomposition().check_consistency(),false);
+	}
+}
+
 BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
 {
 	// Domain
@@ -919,6 +1019,7 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
 	k = std::pow(k, 1/3.);
 	Test3D(domain3,k);
 	Test3D_complex(domain3,k);
+	Test3D_dup(domain3,k);
 }
 
 BOOST_AUTO_TEST_CASE( grid_dist_id_sub_iterator_test_use)
diff --git a/src/Grid/grid_dist_key.hpp b/src/Grid/grid_dist_key.hpp
index 9550a69419b3e04a2e9dbce8e498aa75825e3212..e62d3b0f812234724e9ddcf30733d481475f0816 100644
--- a/src/Grid/grid_dist_key.hpp
+++ b/src/Grid/grid_dist_key.hpp
@@ -40,6 +40,24 @@ public:
 		return key;
 	}
 
+	/* \brief Check if two key are the same
+	 *
+	 * \param key_t key to check
+	 *
+	 * \return true if the two key are equal
+	 *
+	 */
+
+	inline bool operator==(const grid_dist_key_dx<dim> & key_t)
+	{
+		if (g_c != key_t.g_c)
+			return false;
+
+		// Check the two key index by index
+
+		return getKey() == key_t.getKey();
+	}
+
 	/*! \brief Create a new key moving the old one
 	 *
 	 * \param i dimension id
diff --git a/src/Makefile.am b/src/Makefile.am
index 3727abe24b6a25830dd5bbd1537aa829a4b3ef97..c5ebc7b889a65f98d954ce340c2a06df7330d858 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,7 @@ pdata_CXXFLAGS = $(CUDA_CFLAGS) $(INCLUDES_PATH) $(METIS_INCLUDE) $(BOOST_CPPFLA
 pdata_CFLAGS = $(CUDA_CFLAGS)
 pdata_LDADD = $(LINKLIBS) -lmetis
 nobase_include_HEADERS = Decomposition/CartDecomposition.hpp Decomposition/common.hpp Decomposition/Decomposition.hpp  Decomposition/ie_ghost.hpp \
-         Decomposition/nn_processor.hpp Decomposition/DistModel.hpp Decomposition/ie_loc_ghost.hpp Decomposition/ORB.hpp \
+         Decomposition/nn_processor.hpp Decomposition/ie_loc_ghost.hpp Decomposition/ORB.hpp \
          Graph/CartesianGraphFactory.hpp \
          Grid/grid_dist_id.hpp Grid/grid_dist_id_iterator.hpp Grid/grid_dist_key.hpp \
          Vector/vector_dist.hpp Vector/vector_dist_iterator.hpp Vector/vector_dist_key.hpp \
diff --git a/src/SubdomainGraphNodes.hpp b/src/SubdomainGraphNodes.hpp
index 888eed979fd4c3b49941ea2f4c6c2664b16c3573..3538dd66c9f419c2c8a17574dc6fac5b4a43c21f 100644
--- a/src/SubdomainGraphNodes.hpp
+++ b/src/SubdomainGraphNodes.hpp
@@ -66,6 +66,25 @@ struct nm_v
 
 	//! total number of properties boost::fusion::vector
 	static const unsigned int max_prop = 8;
+    
+    //! default constructor
+    nm_v(){
+        
+    }
+    
+    template <unsigned int dim, typename Mem> inline nm_v(const encapc<dim,nm_v,Mem> & p)
+    {
+        boost::fusion::at_c<0>(data) = p.template get<0>();
+        boost::fusion::at_c<1>(data) = p.template get<1>();
+        boost::fusion::at_c<2>(data) = p.template get<2>();
+        boost::fusion::at_c<3>(data) = p.template get<3>();
+        boost::fusion::at_c<4>(data) = p.template get<4>();
+        boost::fusion::at_c<5>(data) = p.template get<5>();
+        boost::fusion::at_c<6>(data) = p.template get<6>();
+        boost::fusion::at_c<7>(data) = p.template get<7>();
+    }
+    
+    
 };
 
 const std::string nm_v::attributes::name[] = {"x","y","z","communication","computation","memory","id","sub_id"};
@@ -132,8 +151,22 @@ struct nm_part_v
 
 	//! total number of properties
 	static const unsigned int max_prop = 2;
+    
+    //! default constructor
+    nm_part_v(){
+        
+    }
+    
+    template <unsigned int dim, typename Mem> inline nm_part_v(const encapc<dim,nm_part_v,Mem> & p)
+    {
+        boost::fusion::at_c<0>(data) = p.template get<0>();
+        boost::fusion::at_c<1>(data) = p.template get<1>();
+    }
+    
 };
 
+
+
 const std::string nm_part_v::attributes::name[] = {"id","sub_id"};
 
 /*! \brief Reduced edge graph node
@@ -156,6 +189,14 @@ struct nm_part_e
 
 	//! total number of properties
 	static const unsigned int max_prop = 0;
+    
+    //! Attributes name
+    struct attributes
+    {
+        static const std::string name[];
+    };
 };
 
+const std::string nm_part_e::attributes::name[] = {"id"};
+
 #endif
diff --git a/src/Vector/vector_dist.hpp b/src/Vector/vector_dist.hpp
index 68111862949df36b8a61d2531c9493fd5badf555..73dc114dce1e74b64e0edfbd72f221df7ff80a77 100644
--- a/src/Vector/vector_dist.hpp
+++ b/src/Vector/vector_dist.hpp
@@ -42,46 +42,58 @@
 
 /*! \brief Distributed vector
  *
- * \tparam dim Dimensionality of the space where the object live
- * \tparam St type of space
- * \tparam prop properties the object store
+ * This class reppresent a distributed vector, the distribution of the structure
+ * is based on the positional information of the elements the vector store
+ *
+ * ## Create a vector of random elements on each processor 2D
+ * \snippet vector_dist_unit_test.hpp Create a vector of random elements on each processor 2D
+ *
+ * ## Create a vector of random elements on each processor 3D
+ * \snippet vector_dist_unit_test.hpp Create a vector of random elements on each processor 3D
+ *
+ * ## Create a vector of elements distributed on a grid like way
+ * \snippet vector_dist_unit_test.hpp Create a vector of elements distributed on a grid like way
+ *
+ * ## Redistribute the particles and sync the ghost properties
+ * \snippet vector_dist_unit_test.hpp Redistribute the particles and sync the ghost properties
+ *
+ * \tparam dim Dimensionality of the space where the elements lives
+ * \tparam St type of space float, double ...
+ * \tparam prop properties the vector element store in OpenFPM data structure format
+ * \tparam Decomposition Decomposition strategy to use CartDecomposition ...
+ * \tparam Memory Memory pool where store the information HeapMemory ...
  *
  */
 
-template<unsigned int dim, typename St, typename prop, typename Decomposition , typename Memory=HeapMemory, bool with_id=false>
+template<unsigned int dim, typename St, typename prop, typename Decomposition , typename Memory=HeapMemory>
 class vector_dist
 {
 private:
 
-	// Ghost marker, all the particle with id > g_m are ghost all with g_m < are real particle
+	//! Ghost marker, all the particle with id > g_m are ghost all with g_m < are real particle
 	size_t g_m = 0;
 
-	// indicate from where the ghost particle start in the vector
-	size_t ghost_pointer;
-
 	//! Space Decomposition
 	Decomposition dec;
 
-	// Particle position vector for each sub-domain the last one is the unassigned particles vector
+	//! Particle position vector, (It has 2 elements) the first has real particles assigned to a processor
+	//! the second element contain unassigned particles
 	Vcluster_object_array<openfpm::vector<Point<dim,St>>> v_pos;
 
-	// Particle properties vector for each sub-domain the last one is the unassigned particles vector
+	//! Particle properties vector, (It has 2 elements) the first has real particles assigned to a processor
+	//! the second element contain unassigned particles
 	Vcluster_object_array<openfpm::vector<prop>> v_prp;
 
-	// Virtual cluster
+	//! Virtual cluster
 	Vcluster & v_cl;
 
-	// Geometrical cell list
-	CellList<dim,St,FAST> geo_cell;
-
-	// Label particles
-
-
 public:
 
 	/*! \brief Constructor
 	 *
-	 * \param Global number of elements
+	 * \param np number of elements
+	 * \param box domain where the vector of elements live
+	 * \param g Ghost margins
 	 *
 	 */
 	vector_dist(size_t np, Box<dim,St> box, Ghost<dim,St> g = Ghost<dim,St>())
@@ -122,22 +134,8 @@ public:
 		// Create the sub-domains
 		dec.setParameters(div,box,g);
 
-		// Get the bounding box containing the processor domain
-		const ::Box<dim,St> & bbound = dec.getProcessorBounds();
-
-		const ::Box<dim,St> & smallest_unit = dec.getSmallestSubdivision();
-
-		// convert spacing divisions
-		size_t n_g[dim];
-
-		for (size_t i = 0 ; i < dim ; i++)
-			n_g[i] = (bbound.getHigh(i) - bbound.getLow(i)) / smallest_unit.getHigh(i);
-
 		Point<dim,St> p;
 		p.zero();
-
-		// Initialize the geo cell list
-		geo_cell.Initialize(box,n_g,p,8);
 	}
 
 	/*! \brief Get the number of minimum sub-domain
@@ -160,9 +158,13 @@ public:
 		return v_pos.get(0).size();
 	}
 
-	/*! \brief Get position of an object
+	/*! \brief Get the position of an element
 	 *
-	 * \param vec_key vector element
+	 * see the vector_dist iterator usage to get an element key
+	 *
+	 * \param vec_key element
+	 *
+	 * \return the position of the element in space
 	 *
 	 */
 	template<unsigned int id> inline auto getPos(vect_dist_key_dx vec_key) -> decltype(v_pos.get(vec_key.getSub()).template get<id>(vec_key.getKey()))
@@ -170,10 +172,15 @@ public:
 		return v_pos.get(vec_key.getSub()).template get<id>(vec_key.getKey());
 	}
 
-	/*! \brief Get the property of the object
+	/*! \brief Get the property of an element
 	 *
+	 * see the vector_dist iterator usage to get an element key
+	 *
+	 * \tparam id property id
 	 * \param vec_key vector element
 	 *
+	 * \return return the selected property of the vector element
+	 *
 	 */
 	template<unsigned int id> inline auto getProp(vect_dist_key_dx vec_key) -> decltype(v_prp.get(vec_key.getSub()).template get<id>(vec_key.getKey()))
 	{
@@ -192,20 +199,14 @@ public:
 		openfpm::vector<prop,PreAllocHeapMemory<2>,openfpm::grow_policy_identity> prp;
 	};
 
-	/*! \brief set the ghost
-	 *
-	 *  \param g ghost
-	 *
-	 */
-	void setGhost()
-	{
-		dec.calculateGhostBoxes();
-	}
-
 	//! It map the processor id with the communication request into map procedure
 	openfpm::vector<size_t> p_map_req;
 
-	/*! \brief It communicate the particle to the respective processor
+	/*! \brief It move all the particles that does not belong to the local processor to the respective processor
+	 *
+	 * In general this function is called after moving the particles to move the
+	 * elements out the local processor. Or just after initialization if each processor
+	 * contain non local particle
 	 *
 	 */
 	void map()
@@ -399,25 +400,22 @@ public:
 		v_prp.get(0).remove(opart,o_p_id);
 	}
 
-	// outgoing particles-id
+	//! For each adjacent processor outgoing particles-ids
 	openfpm::vector<openfpm::vector<size_t>> opart;
 
-	// Each entry contain the size of the ghost sending buffer
+	//! For each adjacent processor the size of the ghost sending buffer
 	openfpm::vector<size_t> ghost_prc_sz;
 
-	// ghost particle labels
-	openfpm::vector<size_t> ghost_lbl_p;
-
-	// Memory for the ghost sending buffer
+	//! Sending buffer for the ghost particles properties
 	Memory g_prp_mem;
 
-	// Memory for the ghost position sending buffer
+	//! Sending buffer for the ghost particles position
 	Memory g_pos_mem;
 
-	/*! \brief It synchronize getting the ghost particles
+	/*! \brief It synchronize the properties and position of the ghost particles
 	 *
-	 * \prp Properties to get
-	 * \opt options WITH_POSITION, it send also the positional information of the particles
+	 * \tparam prp list of properties to get synchronize
+	 * \param opt options WITH_POSITION, it send also the positional information of the particles
 	 *
 	 */
 	template<int... prp> void ghost_get(size_t opt = WITH_POSITION)
@@ -613,13 +611,13 @@ public:
 		}
 	}
 
-	// Receiving size
+	//! For each adjacent processor it store the size of the receiving message in byte
 	openfpm::vector<size_t> recv_sz;
 
-	// Receiving buffer for particles ghost get
+	//! For each adjacent processot it store the received message
 	openfpm::vector<HeapMemory> recv_mem_gg;
 
-	/*! \brief Call-back to allocate buffer to receive incoming objects (particles)
+	/*! \brief Call-back to allocate buffer to receive incoming elements (particles)
 	 *
 	 * \param msg_i message size required to receive from i
 	 * \param total_msg message size to receive from all the processors
@@ -632,7 +630,7 @@ public:
 	 */
 	static void * msg_alloc_ghost_get(size_t msg_i ,size_t total_msg, size_t total_p, size_t i, size_t ri, void * ptr)
 	{
-		vector_dist<dim,St,prop,Decomposition,Memory,with_id> * v = static_cast<vector_dist<dim,St,prop,Decomposition,Memory,with_id> *>(ptr);
+		vector_dist<dim,St,prop,Decomposition,Memory> * v = static_cast<vector_dist<dim,St,prop,Decomposition,Memory> *>(ptr);
 
 		v->recv_sz.resize(v->dec.getNNProcessors());
 		v->recv_mem_gg.resize(v->dec.getNNProcessors());
@@ -647,32 +645,32 @@ public:
 		return v->recv_mem_gg.get(lc_id).getPointer();
 	}
 
-	// Heap memory receiver
+	//! Receive buffer for global communication
 	HeapMemory hp_recv;
 
-	// vector v_proc
+	//! For each message contain the processor from which processor come from
 	openfpm::vector<size_t> v_proc;
 
-	// Receive counter
+	//! Total size of the received buffer
 	size_t recv_cnt;
 
-	/*! \brief Message allocation
+	/*! \brief Call-back to allocate buffer to receive incoming elements (particles)
 	 *
-	 * \param message size required to receive from i
-	 * \param total message size to receive from all the processors
-	 * \param the total number of processor want to communicate with you
+	 * \param msg_i size required to receive the message from i
+	 * \param total_msg total size to receive from all the processors
+	 * \param total_p the total number of processor that want to communicate with you
 	 * \param i processor id
 	 * \param ri request id (it is an id that goes from 0 to total_p, and is unique
 	 *           every time message_alloc is called)
 	 * \param ptr a pointer to the vector_dist structure
 	 *
-	 * \return the pointer where to store the message
+	 * \return the pointer where to store the message for the processor i
 	 *
 	 */
 	static void * message_alloc_map(size_t msg_i ,size_t total_msg, size_t total_p, size_t i, size_t ri, void * ptr)
 	{
 		// cast the pointer
-		vector_dist<dim,St,prop,Decomposition,Memory,with_id> * vd = static_cast<vector_dist<dim,St,prop,Decomposition,Memory,with_id> *>(ptr);
+		vector_dist<dim,St,prop,Decomposition,Memory> * vd = static_cast<vector_dist<dim,St,prop,Decomposition,Memory> *>(ptr);
 
 		// Resize the receive buffer, and the size of each message buffer
 		vd->hp_recv.resize(total_msg);
@@ -743,7 +741,7 @@ public:
 
 	/*! \brief Output particle position and properties
 	 *
-	 * \param File output
+	 * \param out output
 	 * \param opt NO_GHOST or WITH_GHOST
 	 *
 	 * \return if the file has been written correctly
@@ -751,18 +749,13 @@ public:
 	 */
 	inline bool write(std::string out, int opt = NO_GHOST)
 	{
-		if (hasEnding(out,".csv"))
-		{
-			// CSVWriter test
-			CSVWriter<openfpm::vector<Point<dim,St>>, openfpm::vector<prop> > csv_writer;
-
-			std::string output = std::to_string(v_cl.getProcessUnitID()) + std::string("_") + out;
+		// CSVWriter test
+		CSVWriter<openfpm::vector<Point<dim,St>>, openfpm::vector<prop> > csv_writer;
 
-			// Write the CSV
-			return csv_writer.write(output,v_pos.get(INTERNAL),v_prp.get(INTERNAL));
-		}
+		std::string output = std::to_string(out + std::to_string(v_cl.getProcessUnitID()) + std::to_string(".csv"));
 
-		return false;
+		// Write the CSV
+		return csv_writer.write(output,v_pos.get(INTERNAL),v_prp.get(INTERNAL));
 	}
 };
 
diff --git a/src/Vector/vector_dist_unit_test.hpp b/src/Vector/vector_dist_unit_test.hpp
index 2f1b974ed3596969fd851ca4aa9f7bfe6d67afa8..b3e45434f31aa5808506c2c6ef0ec0343687ba6f 100644
--- a/src/Vector/vector_dist_unit_test.hpp
+++ b/src/Vector/vector_dist_unit_test.hpp
@@ -26,13 +26,15 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
 	// Convert the request of having a minimum n_sub number of sub-sub domain into grid decompsition of the space
 	size_t sz = CartDecomposition<2,float>::getDefaultGrid(n_sub);
 
+	//! [Create a vector of elements distributed on a grid like way]
+
 	Box<2,float> box({0.0,0.0},{1.0,1.0});
 	size_t g_div[]= {sz,sz};
 
 	// number of particles
 	size_t np = sz * sz;
 
-	// Calculate the number of objects this processor is going to obtain
+	// Calculate the number of elements this processor is going to obtain
 	size_t p_np = np / v_cl.getProcessingUnits();
 
 	// Get non divisible part
@@ -41,7 +43,7 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
 	// Get the offset
 	size_t offset = v_cl.getProcessUnitID() * p_np + std::min(v_cl.getProcessUnitID(),r);
 
-	// Distribute the remain objects
+	// Distribute the remain elements
 	if (v_cl.getProcessUnitID() < r)
 		p_np++;
 
@@ -83,18 +85,19 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
 		++it;
 	}
 
-	// Both iterators must signal the end, and the number of object in the vector, must the equal to the
+	//! [Create a vector of elements distributed on a grid like way]
+
+	// Both iterators must signal the end, and the number of elements in the vector, must the equal to the
 	// predicted one
 	BOOST_REQUIRE_EQUAL(v_it.isNext(),false);
 	BOOST_REQUIRE_EQUAL(it.isNext(),false);
 	BOOST_REQUIRE_EQUAL(cobj,p_np);
 
+	//! [Redistribute the particles and sync the ghost properties]
+
 	// redistribute the particles according to the decomposition
 	vd.map();
 
-	// Fill the scalar with the particle position
-	const auto & ct = vd.getDecomposition();
-
 	v_it = vd.getIterator();
 
 	while (v_it.isNext())
@@ -110,14 +113,10 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
 		++v_it;
 	}
 
-	//! Output the decomposition
-	ct.write(".");
-
 	// do a ghost get
 	vd.template ghost_get<p::s,p::v>();
 
-	// Debug write the particles with GHOST
-	vd.write("Particles_with_ghost.csv",WITH_GHOST);
+	//! [Redistribute the particles and sync the ghost properties]
 
 	// Get the decomposition
 	const auto & dec = vd.getDecomposition();
@@ -214,6 +213,9 @@ BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use_2d )
 	for ( ; k >= 2 ; k-= decrement(k,big_step) )
 	{
 		BOOST_TEST_CHECKPOINT( "Testing 2D vector k=" << k );
+
+		//! [Create a vector of random elements on each processor 2D]
+
 		Box<2,float> box({0.0,0.0},{1.0,1.0});
 		vector_dist<2,float, Point_test<float>, CartDecomposition<2,float> > vd(k,box);
 
@@ -231,6 +233,8 @@ BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use_2d )
 
 		vd.map();
 
+		//! [Create a vector of random elements on each processor 2D]
+
 		// Check if we have all the local particles
 		size_t cnt = 0;
 		const CartDecomposition<2,float> & ct = vd.getDecomposition();
@@ -278,6 +282,9 @@ BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use_3d )
 	for ( ; k >= 2 ; k-= decrement(k,big_step) )
 	{
 		BOOST_TEST_CHECKPOINT( "Testing 3D vector k=" << k );
+
+		//! [Create a vector of random elements on each processor 3D]
+
 		Box<3,float> box({0.0,0.0,0.0},{1.0,1.0,1.0});
 		vector_dist<3,float, Point_test<float>, CartDecomposition<3,float> > vd(k,box);
 
@@ -296,6 +303,8 @@ BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use_3d )
 
 		vd.map();
 
+		//! [Create a vector of random elements on each processor 3D]
+
 		// Check if we have all the local particles
 		size_t cnt = 0;
 		const CartDecomposition<3,float> & ct = vd.getDecomposition();
diff --git a/src/unit_test_init_cleanup.hpp b/src/unit_test_init_cleanup.hpp
index 0cbd6fd73f5d937a603ee080de201e549c616c35..12b98f01e423c571ff0c5d6b06a5eec2cf822b5a 100644
--- a/src/unit_test_init_cleanup.hpp
+++ b/src/unit_test_init_cleanup.hpp
@@ -12,7 +12,7 @@
 
 struct ut_start {
     ut_start()   { BOOST_TEST_MESSAGE("Initialize global VCluster"); init_global_v_cluster(&boost::unit_test::framework::master_test_suite().argc,&boost::unit_test::framework::master_test_suite().argv); }
-    ~ut_start()  { BOOST_TEST_MESSAGE("Delete global VClster");delete(global_v_cluster); }
+    ~ut_start()  { BOOST_TEST_MESSAGE("Delete global VClster");delete_global_v_cluster(); }
 };
 
 //____________________________________________________________________________//