diff --git a/bh_tree_mpi/CMakeLists.txt b/bh_tree_mpi/CMakeLists.txt
index 8ec5bbd22d8a8e1a44026822f4d863a3b1d38a58..2047fdec0ab0cac246ea84419ff603fd09b575f8 100644
--- a/bh_tree_mpi/CMakeLists.txt
+++ b/bh_tree_mpi/CMakeLists.txt
@@ -2,10 +2,13 @@ cmake_minimum_required (VERSION 2.6)
 project (bh_tree_mpi)
 
 find_package(MPI REQUIRED)
-include_directories(${MPI_INCLUDE_PATH})
+include_directories(${MPI_INCLUDE_PATH} datastructures simulation)
+
+add_subdirectory(datastructures)
+add_subdirectory(simulation)
 
 add_executable(bh_tree_mpi mpimain.cpp)
-target_link_libraries(bh_tree_mpi ${MPI_LIBRARIES})
+target_link_libraries(bh_tree_mpi datastructures simulation ${MPI_LIBRARIES})
 
 if(MPI_COMPILE_FLAGS)
   set_target_properties(bh_tree_mpi PROPERTIES
diff --git a/bh_tree_mpi/BarnesHutTree.cpp b/bh_tree_mpi/datastructures/BarnesHutTree.cpp
similarity index 100%
rename from bh_tree_mpi/BarnesHutTree.cpp
rename to bh_tree_mpi/datastructures/BarnesHutTree.cpp
diff --git a/bh_tree_mpi/BarnesHutTree.hpp b/bh_tree_mpi/datastructures/BarnesHutTree.hpp
similarity index 100%
rename from bh_tree_mpi/BarnesHutTree.hpp
rename to bh_tree_mpi/datastructures/BarnesHutTree.hpp
diff --git a/bh_tree_mpi/Body.cpp b/bh_tree_mpi/datastructures/Body.cpp
similarity index 100%
rename from bh_tree_mpi/Body.cpp
rename to bh_tree_mpi/datastructures/Body.cpp
diff --git a/bh_tree_mpi/Body.hpp b/bh_tree_mpi/datastructures/Body.hpp
similarity index 100%
rename from bh_tree_mpi/Body.hpp
rename to bh_tree_mpi/datastructures/Body.hpp
diff --git a/bh_tree_mpi/Box.cpp b/bh_tree_mpi/datastructures/Box.cpp
similarity index 100%
rename from bh_tree_mpi/Box.cpp
rename to bh_tree_mpi/datastructures/Box.cpp
diff --git a/bh_tree_mpi/Box.hpp b/bh_tree_mpi/datastructures/Box.hpp
similarity index 100%
rename from bh_tree_mpi/Box.hpp
rename to bh_tree_mpi/datastructures/Box.hpp
diff --git a/bh_tree_mpi/datastructures/CMakeLists.txt b/bh_tree_mpi/datastructures/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1efa115feb192b160e66460dfef577f1fed8c14f
--- /dev/null
+++ b/bh_tree_mpi/datastructures/CMakeLists.txt
@@ -0,0 +1,2 @@
+file( GLOB datastructures_SOURCES *.hpp *.cpp )
+add_library( datastructures ${datastructures_SOURCES} )
\ No newline at end of file
diff --git a/bh_tree_mpi/Node.cpp b/bh_tree_mpi/datastructures/Node.cpp
similarity index 100%
rename from bh_tree_mpi/Node.cpp
rename to bh_tree_mpi/datastructures/Node.cpp
diff --git a/bh_tree_mpi/Node.hpp b/bh_tree_mpi/datastructures/Node.hpp
similarity index 100%
rename from bh_tree_mpi/Node.hpp
rename to bh_tree_mpi/datastructures/Node.hpp
diff --git a/bh_tree_mpi/Tree.cpp b/bh_tree_mpi/datastructures/Tree.cpp
similarity index 100%
rename from bh_tree_mpi/Tree.cpp
rename to bh_tree_mpi/datastructures/Tree.cpp
diff --git a/bh_tree_mpi/Tree.hpp b/bh_tree_mpi/datastructures/Tree.hpp
similarity index 97%
rename from bh_tree_mpi/Tree.hpp
rename to bh_tree_mpi/datastructures/Tree.hpp
index d895754c018add08914e22a7fb68cecbef4fbc78..4609e4ad9ef94312d32caf7f49bb5448cbc20608 100644
--- a/bh_tree_mpi/Tree.hpp
+++ b/bh_tree_mpi/datastructures/Tree.hpp
@@ -18,7 +18,6 @@ namespace nbody {
 		friend class Node;
 	protected:
 		Node* nodes;
-		//Control control;
 		unsigned int maxLeafBodies;
 	public:
 		static vector<Body> dubinskiParse(string filename);
diff --git a/bh_tree_mpi/main.cpp b/bh_tree_mpi/main.cpp
index 134361eaacbc71a36aa4449ce83438b9e563a0ed..b295db1f51579a10f7f159cd92e973977e28987e 100644
--- a/bh_tree_mpi/main.cpp
+++ b/bh_tree_mpi/main.cpp
@@ -1,5 +1,5 @@
-#include "BarnesHutTree.hpp"
-#include "MpiSimulation.hpp"
+#include <BarnesHutTree.hpp>
+#include <MpiSimulation.hpp>
 #include <iostream>
 #include <mpi.h>
 
diff --git a/bh_tree_mpi/mpimain.cpp b/bh_tree_mpi/mpimain.cpp
index 134361eaacbc71a36aa4449ce83438b9e563a0ed..b295db1f51579a10f7f159cd92e973977e28987e 100644
--- a/bh_tree_mpi/mpimain.cpp
+++ b/bh_tree_mpi/mpimain.cpp
@@ -1,5 +1,5 @@
-#include "BarnesHutTree.hpp"
-#include "MpiSimulation.hpp"
+#include <BarnesHutTree.hpp>
+#include <MpiSimulation.hpp>
 #include <iostream>
 #include <mpi.h>
 
diff --git a/bh_tree_mpi/simulation/CMakeLists.txt b/bh_tree_mpi/simulation/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..2dc47624544acaeed9c05b2aa0b19ea384e526f0
--- /dev/null
+++ b/bh_tree_mpi/simulation/CMakeLists.txt
@@ -0,0 +1,3 @@
+file( GLOB simulation_SOURCES *.hpp *.cpp )
+include_directories(../datastructures)
+add_library( simulation ${simulation_SOURCES} )
\ No newline at end of file
diff --git a/bh_tree_mpi/MpiBodyComm.cpp b/bh_tree_mpi/simulation/MpiBodyComm.cpp
similarity index 100%
rename from bh_tree_mpi/MpiBodyComm.cpp
rename to bh_tree_mpi/simulation/MpiBodyComm.cpp
diff --git a/bh_tree_mpi/MpiBodyComm.hpp b/bh_tree_mpi/simulation/MpiBodyComm.hpp
similarity index 96%
rename from bh_tree_mpi/MpiBodyComm.hpp
rename to bh_tree_mpi/simulation/MpiBodyComm.hpp
index 2f71abdda40559a81bb5b33e3c4021cf49e09006..24f38053aa29fdd6d11ef25a7e77718af08ce3be 100644
--- a/bh_tree_mpi/MpiBodyComm.hpp
+++ b/bh_tree_mpi/simulation/MpiBodyComm.hpp
@@ -4,7 +4,7 @@
 
 #include <mpi.h>
 #include <vector>
-#include "Body.hpp"
+#include <Body.hpp>
 
 namespace nbody {
 	using namespace std;
diff --git a/bh_tree_mpi/MpiSimulation.cpp b/bh_tree_mpi/simulation/MpiSimulation.cpp
similarity index 98%
rename from bh_tree_mpi/MpiSimulation.cpp
rename to bh_tree_mpi/simulation/MpiSimulation.cpp
index aca3c7c0121cbc1ae67207db30b8f5870a94c417..c9c6c2c7c4a8d4b973d86f6bfd261457df060777 100644
--- a/bh_tree_mpi/MpiSimulation.cpp
+++ b/bh_tree_mpi/simulation/MpiSimulation.cpp
@@ -1,10 +1,10 @@
 #include <iostream>
 #include <cmath>
-#include "Body.hpp"
-#include "Box.hpp"
+#include <Body.hpp>
+#include <Box.hpp>
+#include <Tree.hpp>
+#include <Node.hpp>
 #include "MpiSimulation.hpp"
-#include "Tree.hpp"
-#include "Node.hpp"
 
 namespace nbody {
 	using namespace std;
diff --git a/bh_tree_mpi/MpiSimulation.hpp b/bh_tree_mpi/simulation/MpiSimulation.hpp
similarity index 100%
rename from bh_tree_mpi/MpiSimulation.hpp
rename to bh_tree_mpi/simulation/MpiSimulation.hpp
diff --git a/bh_tree_mpi/PthreadSimulation.cpp b/bh_tree_mpi/simulation/PthreadSimulation.cpp
similarity index 100%
rename from bh_tree_mpi/PthreadSimulation.cpp
rename to bh_tree_mpi/simulation/PthreadSimulation.cpp
diff --git a/bh_tree_mpi/PthreadSimulation.hpp b/bh_tree_mpi/simulation/PthreadSimulation.hpp
similarity index 100%
rename from bh_tree_mpi/PthreadSimulation.hpp
rename to bh_tree_mpi/simulation/PthreadSimulation.hpp
diff --git a/bh_tree_mpi/ReadWriteLock.cpp b/bh_tree_mpi/simulation/ReadWriteLock.cpp
similarity index 100%
rename from bh_tree_mpi/ReadWriteLock.cpp
rename to bh_tree_mpi/simulation/ReadWriteLock.cpp
diff --git a/bh_tree_mpi/ReadWriteLock.hpp b/bh_tree_mpi/simulation/ReadWriteLock.hpp
similarity index 100%
rename from bh_tree_mpi/ReadWriteLock.hpp
rename to bh_tree_mpi/simulation/ReadWriteLock.hpp
diff --git a/bh_tree_mpi/Simulation.cpp b/bh_tree_mpi/simulation/Simulation.cpp
similarity index 100%
rename from bh_tree_mpi/Simulation.cpp
rename to bh_tree_mpi/simulation/Simulation.cpp
diff --git a/bh_tree_mpi/Simulation.hpp b/bh_tree_mpi/simulation/Simulation.hpp
similarity index 100%
rename from bh_tree_mpi/Simulation.hpp
rename to bh_tree_mpi/simulation/Simulation.hpp