diff --git a/src/.deps/pdata-HeapMemory.Po b/src/.deps/pdata-HeapMemory.Po
index 42e2989ad7e6df81a5a55313471c01d127dc00f0..fdc68bd49c847939d37f93ea44387a05f0279fac 100644
--- a/src/.deps/pdata-HeapMemory.Po
+++ b/src/.deps/pdata-HeapMemory.Po
@@ -74,9 +74,10 @@ pdata-HeapMemory.o: ../../OpenFPM_devices/src/memory/HeapMemory.cpp \
  /usr/include/sys/types.h /usr/include/sys/select.h \
  /usr/include/bits/select.h /usr/include/bits/sigset.h \
  /usr/include/sys/sysmacros.h /usr/include/alloca.h \
- /usr/include/bits/stdlib-float.h /usr/include/c++/4.9.2/cstdio \
- /usr/include/libio.h /usr/include/_G_config.h \
- /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+ /usr/include/bits/stdlib-bsearch.h /usr/include/bits/stdlib-float.h \
+ /usr/include/c++/4.9.2/cstdio /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \
+ /usr/include/bits/sys_errlist.h /usr/include/bits/stdio.h \
  /usr/include/c++/4.9.2/cerrno /usr/include/errno.h \
  /usr/include/bits/errno.h /usr/include/linux/errno.h \
  /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \
@@ -301,6 +302,8 @@ pdata-HeapMemory.o: ../../OpenFPM_devices/src/memory/HeapMemory.cpp \
 
 /usr/include/alloca.h:
 
+/usr/include/bits/stdlib-bsearch.h:
+
 /usr/include/bits/stdlib-float.h:
 
 /usr/include/c++/4.9.2/cstdio:
@@ -313,6 +316,8 @@ pdata-HeapMemory.o: ../../OpenFPM_devices/src/memory/HeapMemory.cpp \
 
 /usr/include/bits/sys_errlist.h:
 
+/usr/include/bits/stdio.h:
+
 /usr/include/c++/4.9.2/cerrno:
 
 /usr/include/errno.h:
diff --git a/src/.deps/pdata-Memleak_check.Po b/src/.deps/pdata-Memleak_check.Po
index 6e9955e576862a4e28f4c0d6599b948c25fd017f..b83f8742ae12520c754559aeb9658d08933cff10 100644
--- a/src/.deps/pdata-Memleak_check.Po
+++ b/src/.deps/pdata-Memleak_check.Po
@@ -71,9 +71,10 @@ pdata-Memleak_check.o: ../../OpenFPM_data/src/Memleak_check.cpp \
  /usr/include/sys/types.h /usr/include/sys/select.h \
  /usr/include/bits/select.h /usr/include/bits/sigset.h \
  /usr/include/sys/sysmacros.h /usr/include/alloca.h \
- /usr/include/bits/stdlib-float.h /usr/include/c++/4.9.2/cstdio \
- /usr/include/libio.h /usr/include/_G_config.h \
- /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+ /usr/include/bits/stdlib-bsearch.h /usr/include/bits/stdlib-float.h \
+ /usr/include/c++/4.9.2/cstdio /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \
+ /usr/include/bits/sys_errlist.h /usr/include/bits/stdio.h \
  /usr/include/c++/4.9.2/cerrno /usr/include/errno.h \
  /usr/include/bits/errno.h /usr/include/linux/errno.h \
  /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \
@@ -302,6 +303,8 @@ pdata-Memleak_check.o: ../../OpenFPM_data/src/Memleak_check.cpp \
 
 /usr/include/alloca.h:
 
+/usr/include/bits/stdlib-bsearch.h:
+
 /usr/include/bits/stdlib-float.h:
 
 /usr/include/c++/4.9.2/cstdio:
@@ -314,6 +317,8 @@ pdata-Memleak_check.o: ../../OpenFPM_data/src/Memleak_check.cpp \
 
 /usr/include/bits/sys_errlist.h:
 
+/usr/include/bits/stdio.h:
+
 /usr/include/c++/4.9.2/cerrno:
 
 /usr/include/errno.h:
diff --git a/src/.deps/pdata-VCluster.Po b/src/.deps/pdata-VCluster.Po
index d5efeff1085c337d501f34e4572da0ccaa1aebee..57771c2608f19a1afb3cd86eac91d3e7405519fd 100644
--- a/src/.deps/pdata-VCluster.Po
+++ b/src/.deps/pdata-VCluster.Po
@@ -78,9 +78,10 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
  /usr/include/sys/types.h /usr/include/sys/select.h \
  /usr/include/bits/select.h /usr/include/bits/sigset.h \
  /usr/include/sys/sysmacros.h /usr/include/alloca.h \
- /usr/include/bits/stdlib-float.h /usr/include/c++/4.9.2/cstdio \
- /usr/include/libio.h /usr/include/_G_config.h \
- /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+ /usr/include/bits/stdlib-bsearch.h /usr/include/bits/stdlib-float.h \
+ /usr/include/c++/4.9.2/cstdio /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \
+ /usr/include/bits/sys_errlist.h /usr/include/bits/stdio.h \
  /usr/include/c++/4.9.2/cerrno /usr/include/errno.h \
  /usr/include/bits/errno.h /usr/include/linux/errno.h \
  /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \
@@ -789,7 +790,8 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
  /usr/include/bits/inf.h /usr/include/bits/nan.h \
  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
- /usr/include/c++/4.9.2/sstream /usr/include/c++/4.9.2/bits/sstream.tcc \
+ /usr/include/bits/mathinline.h /usr/include/c++/4.9.2/sstream \
+ /usr/include/c++/4.9.2/bits/sstream.tcc \
  /usr/include/boost/type_traits/is_compound.hpp \
  /usr/include/boost/type_traits/is_copy_constructible.hpp \
  /usr/include/boost/noncopyable.hpp \
@@ -998,11 +1000,6 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
  ../../OpenFPM_vcluster/src/MPI_wrapper/MPI_IallreduceW.hpp \
  ../../OpenFPM_vcluster/src/MPI_wrapper/MPI_IrecvW.hpp \
  ../../OpenFPM_vcluster/src/MPI_wrapper/MPI_IsendW.hpp \
- ../../OpenFPM_data/src/util/check_no_pointers.hpp \
- ../../OpenFPM_data/src/util/common.hpp \
- ../../OpenFPM_data/src/util/util_debug.hpp \
- /usr/include/c++/4.9.2/cxxabi.h \
- /usr/include/c++/4.9.2/x86_64-redhat-linux/bits/cxxabi_tweaks.h \
  ../../OpenFPM_vcluster/src/util/Vcluster_log.hpp \
  /usr/include/c++/4.9.2/fstream /usr/include/c++/4.9.2/bits/codecvt.h \
  /usr/include/c++/4.9.2/x86_64-redhat-linux/bits/basic_file.h \
@@ -1226,6 +1223,8 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
 
 /usr/include/alloca.h:
 
+/usr/include/bits/stdlib-bsearch.h:
+
 /usr/include/bits/stdlib-float.h:
 
 /usr/include/c++/4.9.2/cstdio:
@@ -1238,6 +1237,8 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
 
 /usr/include/bits/sys_errlist.h:
 
+/usr/include/bits/stdio.h:
+
 /usr/include/c++/4.9.2/cerrno:
 
 /usr/include/errno.h:
@@ -2738,6 +2739,8 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
 
 /usr/include/bits/mathcalls.h:
 
+/usr/include/bits/mathinline.h:
+
 /usr/include/c++/4.9.2/sstream:
 
 /usr/include/c++/4.9.2/bits/sstream.tcc:
@@ -3184,16 +3187,6 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
 
 ../../OpenFPM_vcluster/src/MPI_wrapper/MPI_IsendW.hpp:
 
-../../OpenFPM_data/src/util/check_no_pointers.hpp:
-
-../../OpenFPM_data/src/util/common.hpp:
-
-../../OpenFPM_data/src/util/util_debug.hpp:
-
-/usr/include/c++/4.9.2/cxxabi.h:
-
-/usr/include/c++/4.9.2/x86_64-redhat-linux/bits/cxxabi_tweaks.h:
-
 ../../OpenFPM_vcluster/src/util/Vcluster_log.hpp:
 
 /usr/include/c++/4.9.2/fstream:
diff --git a/src/.deps/pdata-main.Po b/src/.deps/pdata-main.Po
index 8e142faf7f771ed582eb6d382401e16ce832c1df..9e9db061c5ee3ac8fb935bdf13bcaca219fa7471 100644
--- a/src/.deps/pdata-main.Po
+++ b/src/.deps/pdata-main.Po
@@ -70,9 +70,10 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
  /usr/include/sys/types.h /usr/include/sys/select.h \
  /usr/include/bits/select.h /usr/include/bits/sigset.h \
  /usr/include/sys/sysmacros.h /usr/include/alloca.h \
- /usr/include/bits/stdlib-float.h /usr/include/c++/4.9.2/cstdio \
- /usr/include/libio.h /usr/include/_G_config.h \
- /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \
+ /usr/include/bits/stdlib-bsearch.h /usr/include/bits/stdlib-float.h \
+ /usr/include/c++/4.9.2/cstdio /usr/include/libio.h \
+ /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \
+ /usr/include/bits/sys_errlist.h /usr/include/bits/stdio.h \
  /usr/include/c++/4.9.2/cerrno /usr/include/errno.h \
  /usr/include/bits/errno.h /usr/include/linux/errno.h \
  /usr/include/asm/errno.h /usr/include/asm-generic/errno.h \
@@ -737,7 +738,8 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
  /usr/include/bits/huge_valf.h /usr/include/bits/huge_vall.h \
  /usr/include/bits/inf.h /usr/include/bits/nan.h \
  /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \
- /usr/include/c++/4.9.2/sstream /usr/include/c++/4.9.2/bits/sstream.tcc \
+ /usr/include/bits/mathinline.h /usr/include/c++/4.9.2/sstream \
+ /usr/include/c++/4.9.2/bits/sstream.tcc \
  /usr/include/boost/type_traits/is_compound.hpp \
  /usr/include/boost/type_traits/is_copy_constructible.hpp \
  /usr/include/boost/noncopyable.hpp \
@@ -1111,6 +1113,7 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
  /usr/include/boost/math/tools/user.hpp \
  /usr/include/boost/detail/fenv.hpp /usr/include/c++/4.9.2/fenv.h \
  /usr/include/fenv.h /usr/include/bits/fenv.h \
+ /usr/include/bits/fenvinline.h \
  /usr/include/boost/math/special_functions/math_fwd.hpp \
  /usr/include/boost/math/special_functions/detail/round_fwd.hpp \
  /usr/include/boost/math/tools/promotion.hpp \
@@ -1306,11 +1309,6 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
  ../../OpenFPM_vcluster/src/MPI_wrapper/MPI_IallreduceW.hpp \
  ../../OpenFPM_vcluster/src/MPI_wrapper/MPI_IrecvW.hpp \
  ../../OpenFPM_vcluster/src/MPI_wrapper/MPI_IsendW.hpp \
- ../../OpenFPM_data/src/util/check_no_pointers.hpp \
- ../../OpenFPM_data/src/util/common.hpp \
- ../../OpenFPM_data/src/util/util_debug.hpp \
- /usr/include/c++/4.9.2/cxxabi.h \
- /usr/include/c++/4.9.2/x86_64-redhat-linux/bits/cxxabi_tweaks.h \
  ../../OpenFPM_vcluster/src/util/Vcluster_log.hpp \
  ../../OpenFPM_data/src/timer.hpp \
  ../../OpenFPM_data/src/Space/SpaceBox.hpp \
@@ -1324,7 +1322,10 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
  ../../OpenFPM_data/src/util/object_util.hpp \
  ../../OpenFPM_data/src/util/object_creator.hpp \
  ../../OpenFPM_data/src/util/util_debug.hpp \
+ /usr/include/c++/4.9.2/cxxabi.h \
+ /usr/include/c++/4.9.2/x86_64-redhat-linux/bits/cxxabi_tweaks.h \
  ../../OpenFPM_data/src/util/check_no_pointers.hpp \
+ ../../OpenFPM_data/src/util/common.hpp \
  ../../OpenFPM_data/src/util/object_s_di.hpp \
  ../../OpenFPM_data/src/util/object_si_d.hpp \
  ../../OpenFPM_devices/src/memory/ExtPreAlloc.hpp \
@@ -1399,6 +1400,7 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
  ../../OpenFPM_vcluster/src/Packer.hpp \
  ../../OpenFPM_data/src/Grid/util.hpp \
  ../../OpenFPM_data/src/Vector/util.hpp \
+ ../../OpenFPM_data/src/util/util_debug.hpp \
  ../../OpenFPM_vcluster/src/Pack_stat.hpp \
  ../../OpenFPM_vcluster/src/Pack_selector.hpp \
  ../../OpenFPM_vcluster/src/Unpacker.hpp \
@@ -1418,7 +1420,8 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
  ../../OpenFPM_data/src/NN/CellList/CellListBal.hpp \
  ../../OpenFPM_data/src/NN/CellList/CellListMem.hpp \
  ../../OpenFPM_data/src/Space/Ghost.hpp ../../OpenFPM_IO/src/util.hpp \
- unit_test_init_cleanup.hpp Decomposition/ORB_unit_test.hpp \
+ unit_test_init_cleanup.hpp Decomposition/CartDecomposition_unit_test.hpp \
+ Decomposition/CartDecomposition.hpp Decomposition/ORB_unit_test.hpp \
  Decomposition/ORB.hpp ../../OpenFPM_data/src/data_type/scalar.hpp \
  Graph/CartesianGraphFactory_unit_test.hpp \
  Graph/CartesianGraphFactory.hpp metis_util_unit_test.hpp metis_util.hpp \
@@ -1430,9 +1433,7 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
  ../../OpenFPM_devices/src/memory/PreAllocHeapMemory.hpp \
  ../../OpenFPM_devices/src/memory/HeapMemory.hpp \
  ../../OpenFPM_IO/src/CSVWriter.hpp \
- ../../OpenFPM_IO/src/csv_multiarray.hpp \
- Decomposition/CartDecomposition_unit_test.hpp \
- Decomposition/CartDecomposition.hpp
+ ../../OpenFPM_IO/src/csv_multiarray.hpp
 
 /usr/include/stdc-predef.h:
 
@@ -1628,6 +1629,8 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
 
 /usr/include/alloca.h:
 
+/usr/include/bits/stdlib-bsearch.h:
+
 /usr/include/bits/stdlib-float.h:
 
 /usr/include/c++/4.9.2/cstdio:
@@ -1640,6 +1643,8 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
 
 /usr/include/bits/sys_errlist.h:
 
+/usr/include/bits/stdio.h:
+
 /usr/include/c++/4.9.2/cerrno:
 
 /usr/include/errno.h:
@@ -3052,6 +3057,8 @@ Graph/CartesianGraphFactory.hpp:
 
 /usr/include/bits/mathcalls.h:
 
+/usr/include/bits/mathinline.h:
+
 /usr/include/c++/4.9.2/sstream:
 
 /usr/include/c++/4.9.2/bits/sstream.tcc:
@@ -3884,6 +3891,8 @@ Graph/CartesianGraphFactory.hpp:
 
 /usr/include/bits/fenv.h:
 
+/usr/include/bits/fenvinline.h:
+
 /usr/include/boost/math/special_functions/math_fwd.hpp:
 
 /usr/include/boost/math/special_functions/detail/round_fwd.hpp:
@@ -4314,16 +4323,6 @@ Grid/grid_dist_id.hpp:
 
 ../../OpenFPM_vcluster/src/MPI_wrapper/MPI_IsendW.hpp:
 
-../../OpenFPM_data/src/util/check_no_pointers.hpp:
-
-../../OpenFPM_data/src/util/common.hpp:
-
-../../OpenFPM_data/src/util/util_debug.hpp:
-
-/usr/include/c++/4.9.2/cxxabi.h:
-
-/usr/include/c++/4.9.2/x86_64-redhat-linux/bits/cxxabi_tweaks.h:
-
 ../../OpenFPM_vcluster/src/util/Vcluster_log.hpp:
 
 ../../OpenFPM_data/src/timer.hpp:
@@ -4352,8 +4351,14 @@ Grid/grid_dist_key.hpp:
 
 ../../OpenFPM_data/src/util/util_debug.hpp:
 
+/usr/include/c++/4.9.2/cxxabi.h:
+
+/usr/include/c++/4.9.2/x86_64-redhat-linux/bits/cxxabi_tweaks.h:
+
 ../../OpenFPM_data/src/util/check_no_pointers.hpp:
 
+../../OpenFPM_data/src/util/common.hpp:
+
 ../../OpenFPM_data/src/util/object_s_di.hpp:
 
 ../../OpenFPM_data/src/util/object_si_d.hpp:
@@ -4502,6 +4507,8 @@ Grid/grid_dist_key.hpp:
 
 ../../OpenFPM_data/src/Vector/util.hpp:
 
+../../OpenFPM_data/src/util/util_debug.hpp:
+
 ../../OpenFPM_vcluster/src/Pack_stat.hpp:
 
 ../../OpenFPM_vcluster/src/Pack_selector.hpp:
@@ -4552,6 +4559,10 @@ dec_optimizer.hpp:
 
 unit_test_init_cleanup.hpp:
 
+Decomposition/CartDecomposition_unit_test.hpp:
+
+Decomposition/CartDecomposition.hpp:
+
 Decomposition/ORB_unit_test.hpp:
 
 Decomposition/ORB.hpp:
@@ -4591,7 +4602,3 @@ Vector/vector_dist_key.hpp:
 ../../OpenFPM_IO/src/CSVWriter.hpp:
 
 ../../OpenFPM_IO/src/csv_multiarray.hpp:
-
-Decomposition/CartDecomposition_unit_test.hpp:
-
-Decomposition/CartDecomposition.hpp:
diff --git a/src/Decomposition/CartDecomposition.hpp b/src/Decomposition/CartDecomposition.hpp
index 2a3df1105bf4412aeb41ff0986a502ec0aa48abc..3a52b44a85aa56c88169414de1317fd9cb450956 100644
--- a/src/Decomposition/CartDecomposition.hpp
+++ b/src/Decomposition/CartDecomposition.hpp
@@ -104,6 +104,23 @@ class CartDecomposition
 		}
 	};
 
+	//! Particular case for internal ghost boxes, in contain the internal local ghost box
+	struct Box_sub_k : Box<dim,T>
+	{
+		// Domain id
+		size_t sub;
+
+		//! k \see getLocalGhostIBoxE
+		long int k;
+
+		Box_sub_k operator=(const Box<dim,T> & box)
+		{
+			::Box<dim,T>::operator=(box);
+
+			return *this;
+		}
+	};
+
 	struct Box_dom
 	{
 		// Intersection between the local sub-domain enlarged by the ghost and the contiguous processor
@@ -115,6 +132,18 @@ class CartDecomposition
 		openfpm::vector_std< Box_sub> ibx;
 	};
 
+	//! Case for local ghost box
+	struct lBox_dom
+	{
+		// Intersection between the local sub-domain enlarged by the ghost and the contiguous processor
+		// sub-domains (External ghost)
+		openfpm::vector_std< Box_sub > ebx;
+
+		// Intersection between the contiguous processor sub-domain enlarged by the ghost with the
+		// local sub-domain (Internal ghost)
+		openfpm::vector_std< Box_sub_k> ibx;
+	};
+
 public:
 
 	//! Type of the domain we are going to decompose
@@ -154,7 +183,7 @@ private:
 	std::unordered_map<size_t, N_box> nn_processor_subdomains;
 
 	//! it contain the internal ghosts of the local processor
-	openfpm::vector<Box_dom> loc_ghost_box;
+	openfpm::vector<lBox_dom> loc_ghost_box;
 
 	//! Structure that contain for each sub-domain box the processor id
 	//! exist for efficient global communication
@@ -176,10 +205,12 @@ private:
 	//! Runtime virtual cluster machine
 	Vcluster & v_cl;
 
-	//! Cell-list that store the geometrical information about the intersection between the local sub-domain
-	//! and the near processor sub-domains
+	//! Cell-list that store the geometrical information of the internal ghost boxes
 	CellList<dim,T,FAST> geo_cell;
 
+	//! Cell-list that store the geometrical information of the local internal ghost boxes
+	CellList<dim,T,FAST> lgeo_cell;
+
 
 	/*! \brief Create internally the decomposition
 	 *
@@ -332,8 +363,12 @@ private:
 
 		// Initialize the geo_cell structure
 		geo_cell.Initialize(domain,div,orig);
+		lgeo_cell.Initialize(domain,div,orig);
 	}
 
+	// Save the ghost boundaries
+	Ghost<dim,T> ghost;
+
 	/*! \brief Create the external local ghost boxes
 	 *
 	 * \param ghost margin to enlarge
@@ -341,13 +376,18 @@ private:
 	 */
 	void create_loc_ghost_ebox(Ghost<dim,T> & ghost)
 	{
+		// Save the ghost
+		this->ghost = ghost;
+
 		loc_ghost_box.resize(sub_domains.size());
 
 		// For each sub-domain
 		for (size_t i = 0 ; i < sub_domains.size() ; i++)
 		{
-			// add a local ghost box
-			loc_ghost_box.add();
+			SpaceBox<dim,T> sub_with_ghost = sub_domains.get(i);
+
+			// enlarge the sub-domain with the ghost
+			sub_with_ghost.enlarge(ghost);
 
 			// intersect with the other local sub-domains
 			for (size_t j = 0 ; j < sub_domains.size() ; j++)
@@ -355,10 +395,6 @@ private:
 				if (i == j)
 					continue;
 
-				SpaceBox<dim,T> sub_with_ghost = sub_domains.get(j);
-				// enlarge the sub-domain with the ghost
-				sub_with_ghost.enlarge(ghost);
-
 				::Box<dim,T> bi;
 
 				bool intersect = sub_with_ghost.Intersect(::SpaceBox<dim,T>(sub_domains.get(j)),bi);
@@ -369,7 +405,18 @@ private:
 					b.sub = j;
 					b = bi;
 
-					loc_ghost_box.get(i).ibx.add(b);
+					// local external ghost box
+					loc_ghost_box.get(i).ebx.add(b);
+
+					// search this box in the internal box of the sub-domain j
+					for (size_t k = 0; k < loc_ghost_box.get(j).ibx.size() ; k++)
+					{
+						if (loc_ghost_box.get(j).ibx.get(k).sub == i)
+						{
+							loc_ghost_box.get(j).ibx.get(k).k = loc_ghost_box.get(i).ebx.size()-1;
+							break;
+						}
+					}
 				}
 			}
 		}
@@ -387,29 +434,26 @@ private:
 		// For each sub-domain
 		for (size_t i = 0 ; i < sub_domains.size() ; i++)
 		{
-			SpaceBox<dim,T> sub_with_ghost = sub_domains.get(i);
-
-			// enlarge the sub-domain with the ghost
-			sub_with_ghost.enlarge(ghost);
-
-			// add a local ghost box
-			loc_ghost_box.add();
-
 			// intersect with the others local sub-domains
 			for (size_t j = 0 ; j < sub_domains.size() ; j++)
 			{
 				if (i == j)
 					continue;
 
+				SpaceBox<dim,T> sub_with_ghost = sub_domains.get(j);
+				// enlarge the sub-domain with the ghost
+				sub_with_ghost.enlarge(ghost);
+
 				::Box<dim,T> bi;
 
-				bool intersect = sub_with_ghost.Intersect(::SpaceBox<dim,T>(sub_domains.get(j)),bi);
+				bool intersect = sub_with_ghost.Intersect(::SpaceBox<dim,T>(sub_domains.get(i)),bi);
 
 				if (intersect == true)
 				{
-					Box_sub b;
+					Box_sub_k b;
 					b.sub = j;
 					b = bi;
+					b.k = -1;
 
 					loc_ghost_box.get(i).ibx.add(b);
 				}
@@ -612,11 +656,12 @@ private:
 						Box_sub sb;
 						sb = b_int.box;
 						sb.sub = i;
+
 						pr_box_int.ibx.add(sb);
 
 						// update the geo_cell list
 
-						// get the boxes this box span
+						// get the cells this box span
 						const grid_key_dx<dim> p1 = geo_cell.getCellGrid(b_int.box.getP1());
 						const grid_key_dx<dim> p2 = geo_cell.getCellGrid(b_int.box.getP2());
 
@@ -706,23 +751,6 @@ public:
 		bbox.zero();
 	}
 
-	/*! \brief Cartesian decomposition constructor, it divide the space in boxes
-	 *
-	 * \param dec is a vector that store how to divide on each dimension
-	 * \param domain is the domain to divide
-	 * \param v_cl are information of the cluster runtime machine
-	 *
-	 */
-	CartDecomposition(std::vector<size_t> dec, Domain<dim,T> domain, Vcluster & v_cl)
-	:gr(dec),cd(domain,dec,0),domain(domain),v_cl(v_cl)
-	{
-		// Reset the box to zero
-		bbox.zero();
-
-		// Create the decomposition
-		CreateDecomposition(v_cl);
-	}
-
 	//! Cartesian decomposition destructor
 	~CartDecomposition()
 	{}
@@ -993,7 +1021,7 @@ p1[0]<-----+         +----> p2[0]
 	 *
 	 *
 	 */
-	void calculateGhostBoxes(Ghost<dim,T> & ghost)
+	void calculateGhostBoxes()
 	{
 #ifdef DEBUG
 		// the ghost margins are assumed to be smaller
@@ -1036,8 +1064,9 @@ p1[0]<-----+         +----> p2[0]
 		// create the internal structures that store ghost information
 		create_box_nn_processor_ext(ghost);
 		create_box_nn_processor_int(ghost);
-		create_loc_ghost_ebox(ghost);
+		// ebox must come after ibox (in this case)
 		create_loc_ghost_ibox(ghost);
+		create_loc_ghost_ebox(ghost);
 	}
 
 	/*! \brief processorID return in which processor the particle should go
@@ -1077,30 +1106,14 @@ p1[0]<-----+         +----> p2[0]
 
 	/*! \brief Set the parameter of the decomposition
 	 *
-     * \param div_ std::vector storing into how many domain to decompose on each dimension
-     * \param domain_ domain to decompose
-	 *
-	 */
-	void setParameters(std::vector<size_t> div_, Domain<dim,T> domain_)
-	{
-		// Set the decomposition parameters
-
-		div = div_;
-		domain = domain_;
-
-		//! Create the decomposition
-
-		CreateDecomposition(v_cl);
-	}
-
-	/*! \brief Set the parameter of the decomposition
-	 *
-     * \param div_ std::vector storing into how many domain to decompose on each dimension
+     * \param div_ storing into how many domain to decompose on each dimension
      * \param domain_ domain to decompose
 	 *
 	 */
-	void setParameters(const size_t (& div_)[dim], Domain<dim,T> domain_)
+	void setParameters(const size_t (& div_)[dim], Domain<dim,T> domain_, Ghost<dim,T> ghost = Ghost<dim,T>())
 	{
+		// set the ghost
+		this->ghost = ghost;
 		// Set the decomposition parameters
 
 		gr.setDimensions(div_);
@@ -1166,11 +1179,9 @@ p1[0]<-----+         +----> p2[0]
 		return sub_domains.get<Object>(id);
 	}
 
-	/*! \brief Get the total number of Hyper-cube
+	/*! \brief Get the total number of sub-domain for the local processor
 	 *
-	 * Get the total number of Hyper-cube
-	 *
-	 * \return The total number of hyper-cube
+	 * \return The total number of sub-domains
 	 *
 	 */
 
@@ -1179,37 +1190,12 @@ p1[0]<-----+         +----> p2[0]
 		return gr.size();
 	}
 
-	/*! \brief produce an hyper-cube approximation of the space decomposition
-	 *
-	 */
-
-	void hyperCube()
-	{
-	}
-
-
-	/*! \brief Get the local grids
-	 *
-	 * Get the local grids
+	/*! \brief Get the local sub-domain
 	 *
-	 * \return the local grids
+	 * \param i (each local processor can have more than one sub-domain)
+	 * \return the sub-domain
 	 *
 	 */
-
-	auto getLocalHyperCubes() -> decltype(sub_domains) &
-	{
-		return sub_domains;
-	}
-
-	/*! \brief Get the local hyper-cubes
-	 *
-	 * Get the local hyper-cubes
-	 *
-	 * \param lc is the id of the space
-	 * \return the local hyper-cube
-	 *
-	 */
-
 	SpaceBox<dim,T> getLocalHyperCube(size_t lc)
 	{
 		// Create a space box
@@ -1227,6 +1213,24 @@ p1[0]<-----+         +----> p2[0]
 		return sp;
 	}
 
+	/*! \brief Get the local sub-domain with ghost extension
+	 *
+	 * \param i (each local processor can have more than one sub-domain)
+	 * \return the sub-domain
+	 *
+	 */
+
+	SpaceBox<dim,T> getSubDomainWithGhost(size_t lc)
+	{
+		// Create a space box
+		SpaceBox<dim,T> sp = sub_domains.get(lc);
+
+		// enlarge with ghost
+		sp.enlarge(ghost);
+
+		return sp;
+	}
+
 	/*! \brief Return the structure that store the physical domain
 	 *
 	 * Return the structure that store the physical domain
@@ -1323,7 +1327,7 @@ p1[0]<-----+         +----> p2[0]
 	 */
 	inline size_t getLocalNEGhost(size_t id)
 	{
-		return loc_ghost_box.get(id).ibx.size();
+		return loc_ghost_box.get(id).ebx.size();
 	}
 
 	/*! \brief Get the number of internal local ghost box for each sub-domain
@@ -1335,7 +1339,7 @@ p1[0]<-----+         +----> p2[0]
 	 */
 	inline size_t getLocalNIGhost(size_t id)
 	{
-		return loc_ghost_box.get(id).ebx.size();
+		return loc_ghost_box.get(id).ibx.size();
 	}
 
 	/*! \brief Get the j Internal ghost box for one processor
@@ -1362,7 +1366,26 @@ p1[0]<-----+         +----> p2[0]
 		return proc_int_box.get(id).ebx.get(j);
 	}
 
+	/*! \brief For the sub-domain i intersected with the sub-domain j enlarged, the associated
+	 *       external ghost box is located in getLocalIGhostBox(j,k) with
+	 *       getLocalIGhostSub(j,k) == i, this function return k
+	 *
+	 *
+	 */
+	inline size_t getLocalIGhostE(size_t i, size_t j)
+	{
+		return loc_ghost_box.get(i).ibx.get(j).k;
+	}
+
 	/*! \brief Get the j internal local ghost box for the i sub-domain of the local processor
+	 *
+	 * \note For the sub-domain i intersected with the sub-domain j enlarged, the associated
+	 *       external ghost box is located in getLocalIGhostBox(j,k) with
+	 *       getLocalIGhostSub(j,k) == i
+	 *
+	 * To get k use getLocalIGhostE
+	 *
+	 * \see getLocalIGhostE
 	 *
 	 * \param i sub-domain
 	 * \param j box
@@ -1371,7 +1394,7 @@ p1[0]<-----+         +----> p2[0]
 	 */
 	inline const ::Box<dim,T> & getLocalIGhostBox(size_t i, size_t j) const
 	{
-		return loc_ghost_box.get(i).ibox.get(j).box;
+		return loc_ghost_box.get(i).ibx.get(j);
 	}
 
 	/*! \brief Get the j external local ghost box for the local processor
@@ -1383,7 +1406,7 @@ p1[0]<-----+         +----> p2[0]
 	 */
 	inline const ::Box<dim,T> & getLocalEGhostBox(size_t i, size_t j) const
 	{
-		return loc_ghost_box.get(i).ebox.get(j).box;
+		return loc_ghost_box.get(i).ebx.get(j);
 	}
 
 	/*! \brief Considering that sub-domain has N internal local ghost box identified
@@ -1396,9 +1419,9 @@ p1[0]<-----+         +----> p2[0]
 	 * \return the box
 	 *
 	 */
-	inline const ::Box<dim,T> & getLocalIGhostSub(size_t i, size_t j) const
+	inline size_t getLocalIGhostSub(size_t i, size_t j) const
 	{
-		return loc_ghost_box.get(i).ibox.get(j).sub;
+		return loc_ghost_box.get(i).ibx.get(j).sub;
 	}
 
 	/*! \brief Considering that sub-domain has N external local ghost box identified
@@ -1411,9 +1434,9 @@ p1[0]<-----+         +----> p2[0]
 	 * \return the box
 	 *
 	 */
-	inline const ::Box<dim,T> & getLocalEGhostSub(size_t i, size_t j) const
+	inline size_t getLocalEGhostSub(size_t i, size_t j) const
 	{
-		return loc_ghost_box.get(i).ebox.get(j).sub;
+		return loc_ghost_box.get(i).ebx.get(j).sub;
 	}
 
 	/*! \brief Get the local sub-domain at witch belong the internal ghost box
@@ -1606,6 +1629,40 @@ p1[0]<-----+         +----> p2[0]
 
 		return true;
 	}
+
+	/*! \brief function to check the consistency of the information of the decomposition
+	 *
+	 * \return false if is inconsistent
+	 *
+	 */
+	bool check_consistency()
+	{
+		//! for each sub-domain
+		for (size_t i = 0 ; i < loc_ghost_box.size() ; i++)
+		{
+			for (size_t j = 0 ; j < loc_ghost_box.get(i).ibx.size() ; j++)
+			{
+				if (loc_ghost_box.get(i).ibx.get(j).k == -1)
+					return false;
+			}
+		}
+
+		// if we have more than one sub domain, the local internal/external ghost boxes must be different
+		// from zero
+
+		if (getNLocalHyperCube() > 1)
+		{
+			for (size_t i = 0 ; i < loc_ghost_box.size() ; i++)
+			{
+				if (loc_ghost_box.get(i).ibx.size() == 0)
+					return false;
+				if (loc_ghost_box.get(i).ebx.size() == 0)
+					return false;
+			}
+		}
+
+		return true;
+	}
 };
 
 
diff --git a/src/Decomposition/CartDecomposition_unit_test.hpp b/src/Decomposition/CartDecomposition_unit_test.hpp
index d358ef7753386693e0ef5d27030695785cd23f88..490cf438810a059f19ff7743f39e939393d25ba0 100644
--- a/src/Decomposition/CartDecomposition_unit_test.hpp
+++ b/src/Decomposition/CartDecomposition_unit_test.hpp
@@ -31,13 +31,13 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_use)
 	for (int i = 0 ; i < 3 ; i++)
 	{div[i] = openfpm::math::round_big_2(pow(n_sub,1.0/3));}
 
-	// Decompose
-	dec.setParameters(div,box);
-
 	Ghost<3,float> g(0.01);
 
+	// Decompose
+	dec.setParameters(div,box,g);
+
 	// create a ghost border
-	dec.calculateGhostBoxes(g);
+	dec.calculateGhostBoxes();
 
 	// For each calculated ghost box
 	for (size_t i = 0 ; i < dec.getNIGhostBox() ; i++)
@@ -61,14 +61,16 @@ BOOST_AUTO_TEST_CASE( CartDecomposition_test_use)
 
 		if (found == false)
 		{
-			int debug = 0;
-			debug++;
-
 			const openfpm::vector<size_t> pr2 = dec.template ghost_processorID<CartDecomposition<3,float>::processor_id>(p);
 		}
 
 		BOOST_REQUIRE_EQUAL(found,true);
 	}
+
+	// Check the consistency
+
+	bool val = dec.check_consistency();
+	BOOST_REQUIRE_EQUAL(val,true);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/Grid/grid_dist_id.hpp b/src/Grid/grid_dist_id.hpp
index 636aa555947d962ca3d64e664644d4b64931141b..b9e6f782fd6255ee0a14f3f8205237824923da09 100644
--- a/src/Grid/grid_dist_id.hpp
+++ b/src/Grid/grid_dist_id.hpp
@@ -267,9 +267,10 @@ class grid_dist_id
 				if (ib.isValid() == false)
 					continue;
 
-				pib.ibx.add();
-				pib.ibx.last() = ib;
-				pib.ibx.last().sub = dec.getLocalIGhostSub(i,j);
+				pib.bid.add();
+				pib.bid.last().box = ib;
+				pib.bid.last().sub = dec.getLocalIGhostSub(i,j);
+				pib.bid.last().k = dec.getLocalIGhostE(i,j);
 			}
 		}
 
@@ -300,13 +301,13 @@ class grid_dist_id
 				::Box<dim,St> ib_dom = dec.getLocalEGhostBox(i,j);
 				::Box<dim,size_t> ib = cd_sm.convertDomainSpaceIntoGridUnits(ib_dom);
 
-				// Check if ib is valid if not it mean that the internal ghost does not contain information so skip it
-				if (ib.isValid() == false)
-					continue;
+				// Warning even if the ib is not a valid in grid unit we are forced to keep it
+				// otherwise the value returned from dec.getLocalEGhostSub(i,j) will point to an
+				// invalid or wrong box
 
-				pib.ebx.add();
-				pib.ebx.last() = ib;
-				pib.ebx.last().sub = dec.getLocalEGhostSub(i,j);
+				pib.bid.add();
+				pib.bid.last().box = ib;
+				pib.bid.last().sub = dec.getLocalEGhostSub(i,j);
 			}
 		}
 
@@ -326,37 +327,45 @@ class grid_dist_id
 			//! For all the internal ghost boxes of each sub-domain
 			for (size_t j = 0 ; j < loc_ig_box.get(i).bid.size() ; j++)
 			{
-				Box<dim,size_t> & bx_src = loc_ig_box.get(i).bid.get(j).box;
+				Box<dim,size_t> bx_src = loc_ig_box.get(i).bid.get(j).box;
+				// convert into local
+				bx_src -= gdb_ext.get(i).origin;
 
-				// sub domain connected
-				size_t sub_id = loc_ig_box.get(i).bid.get(j).sub;
+				// sub domain connected with external box
+				size_t sub_id_dst = loc_ig_box.get(i).bid.get(j).sub;
 
 				// local external ghost box connected
-				size_t e_box_sub = loc_ig_box.get(i).bid.get(j).e_b;
+				size_t k = loc_ig_box.get(i).bid.get(j).k;
 
-				Box<dim,size_t> & bx_dst = loc_eg_box.get(sub_id).bid.get(e_box_sub).box;
+				Box<dim,size_t> bx_dst = loc_eg_box.get(sub_id_dst).bid.get(k).box;
+
+				// convert into local
+				bx_dst -= gdb_ext.get(sub_id_dst).origin;
 
 				// create 2 sub grid iterator
 				grid_key_dx_iterator_sub<dim> sub_src(loc_grid.get(i).getGrid(),bx_src.getKP1(),bx_src.getKP2());
-				grid_key_dx_iterator_sub<dim> sub_dst(loc_grid.get(sub_id).getGrid(),bx_dst.getKP1(),bx_dst.getKP2());
+				grid_key_dx_iterator_sub<dim> sub_dst(loc_grid.get(sub_id_dst).getGrid(),bx_dst.getKP1(),bx_dst.getKP2());
 
 #ifdef DEBUG
 
+				if (loc_eg_box.get(sub_id_dst).bid.get(k).sub != i)
+					std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " source and destination are not correctly linked" << "\n";
+
 				if (sub_src.getVolume() != sub_dst.getVolume())
 					std::cerr << "Error " << __FILE__ << ":" << __LINE__ << " source and destination does not match in size" << "\n";
 
 #endif
 
 				const auto & gs = loc_grid.get(i);
-				auto & gd = loc_grid.get(sub_id);
+				auto & gd = loc_grid.get(sub_id_dst);
 
 				while (sub_src.isNext())
 				{
 					// Option 1
-					gd.set(sub_src.get(),gs,sub_src.get());
+					gd.set(sub_dst.get(),gs,sub_src.get());
 
 					// Option 2
-					gd.get_o(sub_src.get()) = gs.get_o(sub_dst.get());
+//					gd.get_o(sub_dst.get()) = gs.get_o(sub_src.get());
 
 					++sub_src;
 					++sub_dst;
@@ -434,13 +443,13 @@ public:
 		{div[i] = openfpm::math::round_big_2(pow(n_sub,1.0/dim));}
 
 		// Create the sub-domains
-		dec.setParameters(div,domain);
+		dec.setParameters(div,domain,ghost);
 
 		// Create local grid
 		Create();
 
 		// Calculate ghost boxes
-		dec.calculateGhostBoxes(ghost);
+		dec.calculateGhostBoxes();
 	}
 
 	/*! \brief Get the object that store the decomposition information
@@ -464,29 +473,15 @@ public:
 		return cd_sm;
 	}
 
-	/*! \brief Create
-	 *
-	 *
-	 */
-
 	/*! \brief Create the grids on memory
 	 *
 	 */
 
 	void Create()
 	{
-		// Box used for rounding error
-//		Box<dim,St> rnd_box;
-//		for (size_t i = 0 ; i < dim ; i++)	{rnd_box.setHigh(i,0.5); rnd_box.setLow(i,0.5);}
-		// Box used for rounding in case of ghost
 		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);}
 
-		// ! Create an hyper-cube approximation.
-		// ! In order to work on grid_dist the decomposition
-		// ! has to be a set of hyper-cube
-		dec.hyperCube();
-
 		// Get the number of local grid needed
 		size_t n_grid = dec.getNLocalHyperCube();
 
@@ -503,39 +498,25 @@ public:
 
 			// Get the local hyper-cube
 			SpaceBox<dim,St> sp = dec.getLocalHyperCube(i);
+			SpaceBox<dim,St> sp_g = dec.getSubDomainWithGhost(i);
 
-			// Convert from SpaceBox<dim,float> to SpaceBox<dim,long int>
+			// Convert from SpaceBox<dim,St> to SpaceBox<dim,long int>
 			SpaceBox<dim,long int> sp_t = cd_sm.convertDomainSpaceIntoGridUnits(sp);
-
-			// convert the ghost from space coordinate to grid units
-			Ghost<dim,St> g_int = ghost;
-			g_int /= cd_sm.getCellBox().getP2();
-
-			// enlarge by 0.5 for rounding
-			g_int.enlarge(g_rnd_box);
-
-			// convert from Ghost<dim,St> to Ghost<dim,long int>
-			Ghost<dim,long int> g_int_t = g_int;
+			SpaceBox<dim,long int> sp_tg = cd_sm.convertDomainSpaceIntoGridUnits(sp_g);
 
 			//! Save the origin of the local grid
-			gdb_ext.last().origin = sp_t.getP1();
-
-			// Center the local grid to zero
-			sp_t -= sp_t.getP1();
+			gdb_ext.last().origin = sp_tg.getP1();
 
 			// 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;
-			gdb_ext.last().Dbox -= g_int_t.getP1();
-			// needed because the last key coordinate is size - 1 on each direction
-			// The origin is the Domain box + ghost, so shift
-			gdb_ext.last().origin += g_int_t.getP1();
+			gdb_ext.last().Dbox -= sp_tg.getP1();
 
-			// Enlarge sp with the Ghost size
-			sp_t.enlarge_fix_P1(g_int_t);
+			// center to zero
+			sp_tg -= sp_tg.getP1();
 
 			// Get the size of the local grid
-			for (size_t i = 0 ; i < dim ; i++) {l_res[i] = (sp_t.getHigh(i) >= 0)?(sp_t.getHigh(i)+1):0;}
+			for (size_t i = 0 ; i < dim ; i++) {l_res[i] = (sp_tg.getHigh(i) >= 0)?(sp_tg.getHigh(i)+1):0;}
 
 			// Set the dimensions of the local grid
 			loc_grid.get(i).template resize<Memory>(l_res);
@@ -637,7 +618,7 @@ public:
 		size_t sub;
 
 		//! external box
-		size_t e_b;
+		size_t k;
 	};
 
 	/*! \brief It store the information about the external ghost box
@@ -752,6 +733,12 @@ public:
 		// Convert the ghost external boxes into grid unit boxes
 		create_eg_box();
 
+		// Convert the local ghost internal boxes into grid unit boxes
+		create_local_ig_box();
+
+		// Convert the local external ghost boxes into grid unit boxes
+		create_local_eg_box();
+
 		// total number of sending vector
 		std::vector<size_t> pap_prp;
 
diff --git a/src/Grid/grid_dist_id_iterator.hpp b/src/Grid/grid_dist_id_iterator.hpp
index 7a50cebc7b8235b67301f3a65f46617f926d884c..0ae0639577d6b2dea038b263d084215ff85646ac 100644
--- a/src/Grid/grid_dist_id_iterator.hpp
+++ b/src/Grid/grid_dist_id_iterator.hpp
@@ -122,7 +122,7 @@ class grid_dist_iterator<dim,device_grid,FREE>
 	 *
 	 */
 
-	grid_dist_iterator<dim,device_grid,FREE> operator++()
+	inline grid_dist_iterator<dim,device_grid,FREE> operator++()
 	{
 		++a_it;
 
@@ -136,7 +136,7 @@ class grid_dist_iterator<dim,device_grid,FREE>
 			g_c++;
 
 			// When the grid has size 0 potentially all the other informations are garbage
-			while (gList[g_c].size() == 0 ) g_c++;
+			while (g_c < gList.size() && (gList[g_c].size() == 0 || gdb_ext.get(g_c).Dbox.isValid() == false ) ) g_c++;
 
 			// get the next grid iterator
 			if (g_c < gList.size())
@@ -153,7 +153,7 @@ class grid_dist_iterator<dim,device_grid,FREE>
 	 * \return true if there is the next, false otherwise
 	 *
 	 */
-	bool isNext()
+	inline bool isNext()
 	{
 		// If there are no other grid stop
 
@@ -168,7 +168,7 @@ class grid_dist_iterator<dim,device_grid,FREE>
 	 * \return the actual key
 	 *
 	 */
-	grid_dist_key_dx<dim> get()
+	inline grid_dist_key_dx<dim> get()
 	{
 		return grid_dist_key_dx<dim>(g_c,a_it.get());
 	}
@@ -239,7 +239,7 @@ class grid_dist_iterator<dim,device_grid,FIXED>
 			g_c++;
 
 			// When the grid has size 0 potentially all the other informations are garbage
-			while (gList[g_c].size() == 0 ) g_c++;
+			while (g_c < gList.size() && gList[g_c].size() == 0 ) g_c++;
 
 			// get the next grid iterator
 			if (g_c < gList.size())
diff --git a/src/Grid/grid_dist_id_unit_test.hpp b/src/Grid/grid_dist_id_unit_test.hpp
index 9be882ec715c591ab8c601313ca47fe879dc2b14..6629ff267e271e136f4528fbbd5ef2ff7e8af7c3 100644
--- a/src/Grid/grid_dist_id_unit_test.hpp
+++ b/src/Grid/grid_dist_id_unit_test.hpp
@@ -58,6 +58,10 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_domain_grid_unit_converter_test)
 		// get the decomposition
 		auto & dec = g_dist.getDecomposition();
 
+		// check the consistency of the decomposition
+		bool val = dec.check_consistency();
+		BOOST_REQUIRE_EQUAL(val,true);
+
 		// for each local volume
 		// Get the number of local grid needed
 		size_t n_grid = dec.getNLocalHyperCube();
@@ -92,6 +96,8 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
 
 	for (long int k = 1026 ; k > 1 ; k-= 33)
 	{
+		std::cout << "Testing: " << k << "\n";
+
 		// grid size
 		size_t sz[2];
 		sz[0] = k;
@@ -103,6 +109,10 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
 		// Distributed grid with id decomposition
 		grid_dist_id<2, float, scalar<float>, CartDecomposition<2,float>> g_dist(sz,domain,g);
 
+		// check the consistency of the decomposition
+		bool val = g_dist.getDecomposition().check_consistency();
+		BOOST_REQUIRE_EQUAL(val,true);
+
 		// Grid sm
 		grid_sm<2,void> info(sz);
 
@@ -142,12 +152,6 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
 			auto key = dom2.get();
 			auto key_g = g_dist.getGKey(key);
 
-			if (key_g.get(0) == 503 && key_g.get(1) == 779)
-			{
-				int debug = 0;
-				debug++;
-			}
-
 			BOOST_REQUIRE_EQUAL(g_dist.template get<0>(key),info.LinId(key_g));
 
 			++dom2;
@@ -168,12 +172,6 @@ BOOST_AUTO_TEST_CASE( grid_dist_id_iterator_test_use)
 			// In this case the boundary condition are non periodic
 			if (g_dist.isInside(key_g))
 			{
-				if (g_dist.template get<0>(key) != info.LinId(key_g))
-				{
-					int debug = 0;
-					debug++;
-				}
-
 				BOOST_REQUIRE_EQUAL(g_dist.template get<0>(key),info.LinId(key_g));
 			}
 
diff --git a/src/Makefile b/src/Makefile
index 9ff90164b05e220dcb359cc424bbe7e69dc6b10f..e9a648097ef05cd3bbd8ada9ad456f3f8d78dc61 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -193,7 +193,7 @@ CUDA_CFLAGS =  -I -I -I/usr/local/cuda/include
 CUDA_LIBS =  -L -L -L/usr/local/cuda/lib64 -lcuda -lcudart
 CXX = mpic++
 CXXDEPMODE = depmode=gcc3
-CXXFLAGS =  --std=c++11 -march=native -mtune=native  -g3  -Wall -O0 
+CXXFLAGS =  --std=c++11 -march=native -mtune=native  -Wall -O3 -g3 -funroll-loops 
 CYGPATH_W = echo
 DEFS = -DHAVE_CONFIG_H
 DEPDIR = .deps
@@ -214,7 +214,7 @@ LTLIBOBJS =
 MAKEINFO = ${SHELL} /home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_pdata/missing makeinfo
 MKDIR_P = /usr/bin/mkdir -p
 NVCC = /usr/local/cuda/bin/nvcc
-NVCCFLAGS =    -g -O0 
+NVCCFLAGS =    -O3 
 NVCC_EXIST = yes
 OBJEXT = o
 PACKAGE = full-package-name
diff --git a/src/Vector/vector_dist.hpp b/src/Vector/vector_dist.hpp
index 4b1a02761605fa2bc7cfa1983fc2f070f434bda5..d52d7cda028eb7f5b17c39bf44cb6d3aec3e663c 100644
--- a/src/Vector/vector_dist.hpp
+++ b/src/Vector/vector_dist.hpp
@@ -77,7 +77,7 @@ public:
 	 * \param Global number of elements
 	 *
 	 */
-	vector_dist(size_t np, Box box)
+	vector_dist(size_t np, Box box, Ghost<point::dims,typename point::coord_type> g = Ghost<point::dims,typename point::coord_type>())
 	:dec(Decomposition(*global_v_cluster)),v_cl(*global_v_cluster)
 	{
 		// Allocate unassigned particles vectors
@@ -106,7 +106,7 @@ public:
 		{div[i] = openfpm::math::round_big_2(pow(n_sub,1.0/point::dims));}
 
 		// Create the sub-domains
-		dec.setParameters(div,box);
+		dec.setParameters(div,box,g);
 
 		// Get the bounding box containing the processor domain
 		const ::Box<point::dims,typename point::coord_type> & bbound = dec.getProcessorBounds();
@@ -173,9 +173,9 @@ public:
 	 *  \param g ghost
 	 *
 	 */
-	void setGhost(Ghost<point::dims,typename point::coord_type> & g)
+	void setGhost()
 	{
-		dec.calculateGhostBoxes(g);
+		dec.calculateGhostBoxes();
 	}
 
 	//! It map the processor id with the communication request into map procedure
diff --git a/src/Vector/vector_dist_unit_test.hpp b/src/Vector/vector_dist_unit_test.hpp
index 837546e12291e09e063151dae0509febb088e5fc..d73d720eacccace1bf34fc6fae9091fd98c9970d 100644
--- a/src/Vector/vector_dist_unit_test.hpp
+++ b/src/Vector/vector_dist_unit_test.hpp
@@ -42,8 +42,11 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
 	grid_key_dx<2> stop(point_div * (v_cl.getProcessUnitID() + 1) - 1,g_div[0]);
 	auto g_sub = g_info.getSubIterator(start,stop);
 
+	// set the ghost based on the radius cut off (make just a little bit smaller than the spacing)
+	Ghost<2,float> g(spacing.get(0) - spacing .get(0) * 0.0001);
+
 	// Vector of particles
-	vector_dist<Point<2,float>, Point_test<float>, Box<2,float>, CartDecomposition<2,float> > vd(g_info.size(),box);
+	vector_dist<Point<2,float>, Point_test<float>, Box<2,float>, CartDecomposition<2,float> > vd(g_info.size(),box,g);
 
 	auto it = vd.getIterator();
 
@@ -57,12 +60,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
 		vd.template getPos<s::x>(key_v)[0] = key.get(0) * spacing[0] + m_spacing[0];
 		vd.template getPos<s::x>(key_v)[1] = key.get(1) * spacing[1] + m_spacing[1];
 
-		if (vd.template getPos<s::x>(key_v)[0] >= 1.0 || vd.template getPos<s::x>(key_v)[1] >= 1.0)
-		{
-			int debug = 0;
-			debug++;
-		}
-
 		++g_sub;
 		++it;
 	}
@@ -94,12 +91,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_ghost )
 		++it;
 	}
 
-	// set the ghost based on the radius cut off (make just a little bit smaller than the spacing)
-	Ghost<2,float> g(spacing.get(0) - spacing .get(0) * 0.0001);
-
-	// set the ghost
-	vd.setGhost(g);
-
 	//! Output the decomposition
 	ct.write(".");
 
diff --git a/src/main.cpp b/src/main.cpp
index bdee86089aaed30fc6d36b449445bb34fbc4c7f0..fe5923ba5cde47805ad87778d49c9de02402728e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -18,11 +18,12 @@
 #include "util.hpp"
 
 #include "unit_test_init_cleanup.hpp"
+#include "Decomposition/CartDecomposition_unit_test.hpp"
 #include "Decomposition/ORB_unit_test.hpp"
 #include "Graph/CartesianGraphFactory_unit_test.hpp"
 #include "metis_util_unit_test.hpp"
 #include "dec_optimizer_unit_test.hpp"
 #include "Grid/grid_dist_id_unit_test.hpp"
 #include "Vector/vector_dist_unit_test.hpp"
-#include "Decomposition/CartDecomposition_unit_test.hpp"
+