diff --git a/AMDiS/CMakeLists.txt b/AMDiS/CMakeLists.txt
index 99d603afac84ca71266f01d4786ba0263fd83bb9..a016d188415936760dac61fff4880b821206aa4a 100644
--- a/AMDiS/CMakeLists.txt
+++ b/AMDiS/CMakeLists.txt
@@ -170,7 +170,7 @@ if(ENABLE_PARALLEL_DOMAIN)
 		DESTINATION lib/parmetis
 	       )
 	set(ENABLE_PARMETIS ON)
-
+	set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};/usr/share/cmake-2.8/Modules/;${CMAKE_SOURCE_DIR}/")
 	find_package(PETSc REQUIRED)
 	include_directories(${PETSC_DIR}/include ${PETSC_DIR}/${PETSC_ARCH}/include)
 	SET(PARALLEL_DOMAIN_AMDIS_SRC
diff --git a/AMDiS/ResolveCompilerPaths.cmake b/AMDiS/ResolveCompilerPaths.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..b398025e95518511f4e06ba218dcef386a4e8eaa
--- /dev/null
+++ b/AMDiS/ResolveCompilerPaths.cmake
@@ -0,0 +1,93 @@
+# ResolveCompilerPaths - this module defines two macros
+#
+# RESOLVE_LIBRARIES (XXX_LIBRARIES LINK_LINE)
+#  This macro is intended to be used by FindXXX.cmake modules.
+#  It parses a compiler link line and resolves all libraries
+#  (-lfoo) using the library path contexts (-L/path) in scope.
+#  The result in XXX_LIBRARIES is the list of fully resolved libs.
+#  Example:
+#
+#    RESOLVE_LIBRARIES (FOO_LIBRARIES "-L/A -la -L/B -lb -lc -ld")
+#
+#  will be resolved to
+#
+#    FOO_LIBRARIES:STRING="/A/liba.so;/B/libb.so;/A/libc.so;/usr/lib/libd.so"
+#
+#  if the filesystem looks like
+#
+#    /A:       liba.so         libc.so
+#    /B:       liba.so libb.so
+#    /usr/lib: liba.so libb.so libc.so libd.so
+#
+#  and /usr/lib is a system directory.
+#
+#  Note: If RESOLVE_LIBRARIES() resolves a link line differently from
+#  the native linker, there is a bug in this macro (please report it).
+#
+# RESOLVE_INCLUDES (XXX_INCLUDES INCLUDE_LINE)
+#  This macro is intended to be used by FindXXX.cmake modules.
+#  It parses a compile line and resolves all includes
+#  (-I/path/to/include) to a list of directories.  Other flags are ignored.
+#  Example:
+#
+#    RESOLVE_INCLUDES (FOO_INCLUDES "-I/A -DBAR='\"irrelevant -I/string here\"' -I/B")
+#
+#  will be resolved to
+#
+#    FOO_INCLUDES:STRING="/A;/B"
+#
+#  assuming both directories exist.
+#  Note: as currently implemented, the -I/string will be picked up mistakenly (cry, cry)
+
+macro (RESOLVE_LIBRARIES LIBS LINK_LINE)
+  string (REGEX MATCHALL "((-L|-l|-Wl)([^\" ]+|\"[^\"]+\")|/[^\" ]+(a|so|dll))" _all_tokens "${LINK_LINE}")
+  set (_libs_found)
+  set (_directory_list)
+  foreach (token ${_all_tokens})
+    if (token MATCHES "-L([^\" ]+|\"[^\"]+\")")
+      # If it's a library path, add it to the list
+      string (REGEX REPLACE "^-L" "" token ${token})
+      string (REGEX REPLACE "//" "/" token ${token})
+      list (APPEND _directory_list ${token})
+    elseif (token MATCHES "^(-l([^\" ]+|\"[^\"]+\")|/[^\" ]+(a|so|dll))")
+      # It's a library, resolve the path by looking in the list and then (by default) in system directories
+      string (REGEX REPLACE "^-l" "" token ${token})
+      set (_root)
+      if (token MATCHES "^/")	# We have an absolute path, add root to the search path
+	set (_root "/")
+      endif (token MATCHES "^/")
+      set (_lib "NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
+      find_library (_lib ${token} HINTS ${_directory_list} ${_root})
+      if (_lib)
+	string (REPLACE "//" "/" _lib ${_lib})
+        list (APPEND _libs_found ${_lib})
+      else (_lib)
+        message (STATUS "Unable to find library ${token}")
+      endif (_lib)
+    endif (token MATCHES "-L([^\" ]+|\"[^\"]+\")")
+  endforeach (token)
+  set (_lib "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE)
+  # only the LAST occurence of each library is required since there should be no circular dependencies
+  if (_libs_found)
+    list (REVERSE _libs_found)
+    list (REMOVE_DUPLICATES _libs_found)
+    list (REVERSE _libs_found)
+  endif (_libs_found)
+  set (${LIBS} "${_libs_found}")
+endmacro (RESOLVE_LIBRARIES)
+
+macro (RESOLVE_INCLUDES INCS COMPILE_LINE)
+  string (REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" _all_tokens "${COMPILE_LINE}")
+  set (_incs_found)
+  foreach (token ${_all_tokens})
+    string (REGEX REPLACE "^-I" "" token ${token})
+    string (REGEX REPLACE "//" "/" token ${token})
+    if (EXISTS ${token})
+      list (APPEND _incs_found ${token})
+    else (EXISTS ${token})
+      message (STATUS "Include directory ${token} does not exist")
+    endif (EXISTS ${token})
+  endforeach (token)
+  list (REMOVE_DUPLICATES _incs_found)
+  set (${INCS} "${_incs_found}")
+endmacro (RESOLVE_INCLUDES)
diff --git a/AMDiS/test/Meshtest/src/Meshtest.cpp b/AMDiS/test/Meshtest/src/Meshtest.cpp
index afc68390c9d9f7079c30f19028b7a618eb0e336b..9588990ec93480e3a92792cf96d273371091ebbe 100644
--- a/AMDiS/test/Meshtest/src/Meshtest.cpp
+++ b/AMDiS/test/Meshtest/src/Meshtest.cpp
@@ -29,7 +29,7 @@ void require(Test l, Test r, std::string message, StringVector& res) {
 }
 
 using namespace AMDiS;
-void testMesh(int dim, int nrEls, int nrVert , StringVector& res) {
+void testMesh(int dim, int nrEls, int nrVert , int nrMacro, StringVector& res) {
 	std::stringstream ss;
 	ss<< dim;
 	Parameters::addGlobalParameter(0, "dimension of world", ss.str());
@@ -42,6 +42,7 @@ void testMesh(int dim, int nrEls, int nrVert , StringVector& res) {
 	require(mesh.getDim(), dim, __LINE__, "mesh dimension");
 	std::stringstream ss2;
 	ss2<<"\ncurrent dimension: "<<dim<<"\n";
+	require(mesh.getNumberOfMacros(), nrMacro, ss2.str() + "number of macro elements",res);
 	require(mesh.getNumberOfElements() , nrEls, ss2.str() + "number of elements",res);
 	require(mesh.getNumberOfVertices(), nrVert, ss2.str() + "number of vertices",res);
 }
@@ -53,9 +54,9 @@ int main(int argc, char** argv) {
   Parameters::addGlobalParameter(0,"testMesh3->macro file name","macro/macro.stand.3d");
 
 	StringVector errorMessages;
-  testMesh(1,1,2, errorMessages);
-  testMesh(2,4,5, errorMessages);
-  testMesh(3,6,8, errorMessages);
+  testMesh(1,0,2,1, errorMessages);
+  testMesh(2,0,5,4, errorMessages);
+  testMesh(3,0,8,6, errorMessages);
 
 	if(errorMessages.size() > 0)
 		std::cout<<" got errors: \n";
diff --git a/AMDiS/test/demoimpl/CMakeLists.txt b/AMDiS/test/demoimpl/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..5fb9409fb9e73eedb5857718ae421de05afd11e6
--- /dev/null
+++ b/AMDiS/test/demoimpl/CMakeLists.txt
@@ -0,0 +1,4 @@
+project(demoimpl)
+  include_directories(${AMDiS_SOURCE_DIR})
+  file(GLOB PROJECTFILES src/*Project.cpp)
+  add_library(demoimpl ${PROJECTFILES})