diff --git a/.gitignore b/.gitignore
index b8bd0267bdf1a5e02793430b53cbbebd6c257f6f..9c145dc6c75c7be8ddf0f53e3a8c0b4ae4056c4c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,3 +26,6 @@
 *.exe
 *.out
 *.app
+
+build
+bin
diff --git a/CMakeLists.txt b/CMakeLists.txt
index afd950191672ee399298b61cd2667734373c2794..18ab49dbc6ead9500d3bef7b4251623640fe3581 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8)
 project(falkolib)
 set(CMAKE_BUILD_TYPE Release)
 add_definitions(-std=c++0x)   # Enabling c++11
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 
 SET(falkolib_RUNTIME_OUTPUT_DIRECTORY ${falkolib_SOURCE_DIR}/bin CACHE PATH "Target for the binaries")
 SET(falkolib_LIBRARY_OUTPUT_DIRECTORY ${falkolib_SOURCE_DIR}/lib CACHE PATH "Target for the libraries")
diff --git a/include/falkolib/Matching/AHTMatcher.h b/include/falkolib/Matching/AHTMatcher.h
index 8dcd985fba4fdfd2e77ef088ab69b00be2f01435..08f2def2908d36d564f6011a6451ce6c8166d0ef 100644
--- a/include/falkolib/Matching/AHTMatcher.h
+++ b/include/falkolib/Matching/AHTMatcher.h
@@ -138,6 +138,8 @@ namespace falkolib {
 
 		/** @brief get best matching given point and an initial guest associations list*/
 		int getBestMatching(const std::vector<T>& v1, const std::vector<T>& v2, const std::vector<std::pair<int, int> >& init, std::vector<std::pair<int, int> >& match) {
+			for (auto &cell : matchesGrid)
+		        cell.clear();
 			for (auto& asso : init) {
 				for (int it = 0; it < thetaSize; ++it) {
 					double theta = thetaRes * (it - thetaSize / 2);