diff --git a/configure.ac b/configure.ac
index 38080b9c4778800240adeaa253060f6c0a6f7510..1ac71bea3e27d553daa150b093c2a313c6f73b95 100755
--- a/configure.ac
+++ b/configure.ac
@@ -47,8 +47,8 @@ fi
 prefix="$prefix/openfpm_devices"
 echo "Installation dir is: $prefix"
 
-AC_PROG_RANLIB
-AM_PROG_AR
+LT_INIT
+AC_SUBST([LIBTOOL_DEPS])
 
 # Checks for programs.
 AC_PROG_CXX
diff --git a/src/Makefile.am b/src/Makefile.am
index b4ce638c4196f9ac4c5ac28d312af24e2db5f43c..5ce956d59d613dc1da85a457499b7e5f4a0354d0 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,6 +7,10 @@ endif
 
 LINKLIBS = $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) $(CUDA_LIBS) $(BOOST_THREAD_LIB)
 
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
+libtool: $(LIBTOOL_DEPS)
+	$(SHELL) ./config.status libtool
+
 noinst_PROGRAMS = mem
 mem_SOURCES = main.cpp memory/HeapMemory.cpp $(CUDA_SOURCES) Memleak_check.cpp
 mem_CXXFLAGS = $(INCLUDES_PATH) $(BOOST_CPPFLAGS) -I/usr/local/include
@@ -22,6 +26,16 @@ libofpmmemory_se2_a_SOURCES = memory/HeapMemory.cpp $(CUDA_SOURCES) memory/PtrMe
 libofpmmemory_se2_a_CXXFLAGS = $(INCLUDES_PATH) $(BOOST_CPPFLAGS) -I/usr/local/include -DSE_CLASS2
 libofpmmemory_se2_a_CFLAGS = 
 
+lib_LTLIBRARIES = libofpmmemory.la libofpmmemory_se2.la
+libofpmmemory_la_SOURCES = memory/HeapMemory.cpp $(CUDA_SOURCES) memory/PtrMemory.cpp Memleak_check.cpp
+libofpmmemory_la_CXXFLAGS = $(INCLUDES_PATH) $(BOOST_CPPFLAGS) -I/usr/local/include
+libofpmmemory_la_CFLAGS =
+
+libofpmmemory_se2_la_SOURCES = memory/HeapMemory.cpp $(CUDA_SOURCES) memory/PtrMemory.cpp Memleak_check.cpp
+libofpmmemory_se2_la_CXXFLAGS = $(INCLUDES_PATH) $(BOOST_CPPFLAGS) -I/usr/local/include -DSE_CLASS2
+libofpmmemory_se2_la_CFLAGS =
+
+
 nobase_include_HEADERS = memory/ExtPreAlloc.hpp memory/BHeapMemory.hpp  memory/HeapMemory.hpp memory/memory.hpp memory/PtrMemory.hpp \
 Memleak_check.hpp util/print_stack.hpp ptr_info.hpp \
 util/se_util.hpp
diff --git a/src/memory/CudaMemory.cu b/src/memory/CudaMemory.cu
index 637b06b63f5b284116acb1f178313ff6d9d0215d..cb241e1728961a7f775bd174c868d36a3e99bc18 100644
--- a/src/memory/CudaMemory.cu
+++ b/src/memory/CudaMemory.cu
@@ -275,8 +275,13 @@ void CudaMemory::deviceToHost()
 
 	CUDA_SAFE_CALL(cudaMemcpy(hm,dm,sz,cudaMemcpyDeviceToHost));
 }
+<<<<<<< HEAD
 
 
+=======
+
+
+>>>>>>> 98033dea8fd01877d50de6bb96078f8b373a4c5a
 /*! \brief Return a readable pointer with your data
  *
  * \return a readable pointer with your data
@@ -314,6 +319,7 @@ void * CudaMemory::getDevicePointer()
 	return dm;
 }
 
+<<<<<<< HEAD
 /*! \brief Return the CUDA device pointer (Do not copy to device)
  *
  * \return CUDA device pointer
@@ -323,4 +329,6 @@ void * CudaMemory::getDevicePointerNoCopy()
 {
 	return dm;
 }
+=======
+>>>>>>> 98033dea8fd01877d50de6bb96078f8b373a4c5a
 
diff --git a/src/memory/ExtPreAlloc.hpp b/src/memory/ExtPreAlloc.hpp
index 3ba28059d1cb36d761866f49429e783ddeea2ed1..a695460731d5b4dce35fecde0a5c75d9be68d135 100644
--- a/src/memory/ExtPreAlloc.hpp
+++ b/src/memory/ExtPreAlloc.hpp
@@ -8,6 +8,8 @@
 #define EXTPREALLOC_HPP_
 
 #include <stddef.h>
+#include "memory.hpp"
+#include <iostream>
 
 /*! Preallocated memory sequence
  *
@@ -24,14 +26,15 @@
 template<typename Mem>
 class ExtPreAlloc : public memory
 {
-	// Actual allocation pointer
+	//! Actual allocation pointer
 	size_t a_seq ;
 
-	// Last allocation size
+	//! Last allocation size
 	size_t l_size;
 
-	// Main class for memory allocation
+	//! Main class for memory allocation
 	Mem * mem;
+
 	//! Reference counter
 	long int ref_cnt;
 
@@ -92,11 +95,10 @@ public:
 		if (sz == 0)
 			return true;
 
-		// Check that the size match
-
 		a_seq = l_size;
 		l_size += sz;
 
+		// Check we do not overflow the allocated memory
 #ifdef SE_CLASS1
 
 		if (l_size > mem->size())
@@ -107,6 +109,25 @@ public:
 		return true;
 	}
 
+	/*! \brief Allocate a chunk of memory
+	 *
+	 * Allocate a chunk of memory
+	 *
+	 * \param sz size of the chunk of memory to allocate in byte
+	 *
+	 */
+	bool allocate_nocheck(size_t sz)
+	{
+		// Zero sized allocation are ignored
+		if (sz == 0)
+			return true;
+
+		a_seq = l_size;
+		l_size += sz;
+
+		return true;
+	}
+
 	/*! \brief Return the end pointer of the previous allocated memory
 	 *
 	 * \return the pointer
@@ -250,6 +271,63 @@ public:
 
 		return s;
 	}
+
+	/*! \brief shift the pointer backward
+	 *
+	 * \warning when you shift backward the pointer, the last allocation is lost
+	 * 			this mean that you have to do again an allocation.
+	 *
+	 * This function is useful to go ahead in memory and fill the memory later on
+	 *
+	 * \code
+
+	  mem.allocate(16); <------ Here we allocate 16 byte but we do not fill it because
+	  	  	  	  	  	  	    subsequently we do another allocation without using mem
+	  unsigned char * start = (unsigned char *)mem.getPointer()
+	  mem.allocate(100)
+
+	  // ...
+	  // ...
+	  // Code that fill mem in some way and do other mem.allocate(...)
+	  // ...
+	  // ...
+
+	  unsigned char * final = (unsigned char *)mem.getPointer()
+	  mem.shift_backward(final - start);
+	  mem.allocate(16);  <------ Here I am getting the same memory that I request for the
+	  	  	  	  	  	  	  	 first allocate
+
+	  // we now fill the memory
+
+	  \endcode
+	 *
+	 *
+	 *
+	 * \param how many byte to shift
+	 *
+	 */
+	void shift_backward(size_t sz)
+	{
+		a_seq -= sz;
+		l_size = a_seq;
+	}
+
+	/*! \brief shift the pointer forward
+	 *
+	 * The same as shift backward, but in this case it move the pointer forward
+	 *
+	 * In general you use this function after the you went back with shift_backward
+	 * and you have to move forward again
+	 *
+	 * \warning when you shift forward the pointer, the last allocation is lost
+	 * 			this mean that you have to do again an allocation.
+	 *
+	 */
+	void shift_forward(size_t sz)
+	{
+		a_seq += sz;
+		l_size = a_seq;
+	}
 };
 
 #endif /* PREALLOCHEAPMEMORY_HPP_ */
diff --git a/src/memory/HeapMemory.cpp b/src/memory/HeapMemory.cpp
index f9c20e3d5a7285a6dfc4295f01fbc0ac691585dc..d450f9904565f2e0a853505e736d4de697827290 100644
--- a/src/memory/HeapMemory.cpp
+++ b/src/memory/HeapMemory.cpp
@@ -11,6 +11,8 @@
 #include <iostream>
 #include <cstdint>
 
+static const int extra_pad = 512;
+
 // If debugging mode include memory leak check
 #ifdef SE_CLASS2
 #include "Memleak_check.hpp"
@@ -26,7 +28,7 @@ bool HeapMemory::allocate(size_t sz)
 {
 	//! Allocate the device memory
 	if (dm == NULL)
-		dmOrig = new byte[sz+alignement];
+		dmOrig = new byte[sz+alignement+extra_pad];
 	else
 		std::cerr << __FILE__ << ":" << __LINE__ << " error memory already allocated\n";
 
@@ -180,7 +182,7 @@ bool HeapMemory::resize(size_t sz)
 	//! Create a new buffer if sz is bigger than the actual size
 	byte * tdm;
 	byte * tdmOrig;
-	tdmOrig = new byte[sz+alignement];
+	tdmOrig = new byte[sz+alignement+extra_pad];
 #ifdef SE_CLASS2
 	check_new(tdmOrig,sz+alignement,HEAPMEMORY_EVENT,0);
 #endif
@@ -242,7 +244,6 @@ void * HeapMemory::getDevicePointerNoCopy()
  * Return a readable pointer with your data
  *
  */
-
 void * HeapMemory::getPointer()
 {
 	return dm;