diff --git a/containers/docker/Dockerfile b/containers/docker/Dockerfile
index fac284f26d2e779dd40fbc2392e22390108d61b5..41568ddfab854a1473671c381f35e3d910a6bac1 100644
--- a/containers/docker/Dockerfile
+++ b/containers/docker/Dockerfile
@@ -54,12 +54,18 @@ ADD src /root/np-tmcode/src
 ADD doc /root/np-tmcode/doc
 ADD build /root/np-tmcode/build
 ADD test_data /root/np-tmcode/test_data
-RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_magma_mpi
-RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 CXX=g++ FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_magma_serial
-RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_lapack_mpi && cd ../build/cluster && ln -s np_cluster_lapack_mpi np_cluster
-RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 CXX=g++ FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_lapack_serial
-RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_legacy_mpi
-RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 CXX=g++ FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_legacy_serial
+#RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_magma_mpi
+RUN cd np-tmcode/build && CXX=mpicxx FC=gfortran ./configure --enable-static --enable-mpi --enable-ilp64 --enable-openmp --with-lapack --with-magma && make clean && make -j && mv cluster/np_cluster cluster/np_cluster_magma_mpi
+#RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 CXX=g++ FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_magma_serial
+RUN cd np-tmcode/build && CXX=g++ FC=gfortran ./configure --enable-static --disable-mpi --enable-ilp64 --enable-openmp --with-lapack --with-magma && make clean && make -j && mv cluster/np_cluster cluster/np_cluster_magma_serial
+#RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_lapack_mpi && cd ../build/cluster && ln -s np_cluster_lapack_mpi np_cluster
+RUN cd np-tmcode/build && CXX=mpicxx FC=gfortran ./configure --enable-static --enable-mpi --enable-ilp64 --enable-openmp --with-lapack --without-magma && make clean && make -j && mv cluster/np_cluster cluster/np_cluster_lapack_mpi && cd cluster && ln -s np_cluster_lapack_mpi np_cluster
+#RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 CXX=g++ FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_lapack_serial
+RUN cd np-tmcode/build && CXX=g++ FC=gfortran ./configure --enable-static --disable-mpi --enable-ilp64 --enable-openmp --with-lapack --without-magma && make clean && make -j && mv cluster/np_cluster cluster/np_cluster_lapack_serial
+#RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_legacy_mpi
+RUN cd np-tmcode/build && CXX=mpicxx FC=gfortran ./configure --enable-static --disable-mpi --enable-ilp64 --enable-openmp --without-lapack --without-magma && make clean && make -j && mv cluster/np_cluster cluster/np_cluster_legacy_mpi
+#RUN cd np-tmcode/src && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe && BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 CXX=g++ FC=gfortran make -j && mv ../build/cluster/np_cluster ../build/cluster/np_cluster_legacy_serial
+RUN cd np-tmcode/build && CXX=g++ FC=gfortran ./configure --enable-static --disable-mpi --enable-ilp64 --disable-openmp --without-lapack --without-magma && make clean && make -j && mv cluster/np_cluster cluster/np_cluster_legacy_serial
 RUN cd np-tmcode/doc/src && doxygen config.dox && cd ../build/latex && make -j
 
 
@@ -78,7 +84,7 @@ COPY --from=np-tmcode-run-dev /root /root
 COPY --from=np-tmcode-run-dev /usr/lib/x86_64-linux-gnu/libmagma.so /usr/lib/x86_64-linux-gnu/libmagma.so
 COPY --from=np-tmcode-run-dev /usr/lib/x86_64-linux-gnu/libmagma.so.2 /usr/lib/x86_64-linux-gnu/libmagma.so.2
 # remove everything which is not needed to run the codes
-RUN cd /root/np-tmcode && find build -name "*.o" -exec rm -v \{\} \; && find build -name "*.gcno" -exec rm -v \{\} \; && cd src && rm -rvf cluster libnptm trapping include sphere Makefile make.inc README.md && cd .. && rm -rvf containers && cd doc && rm -rvf src && cd build/latex && rm -rvf *.tex *.out *.sty *.ind *.log *.toc *.ilg *.idx *.aux *.eps Makefile class*.pdf
+RUN cd /root/np-tmcode && find build -name "*.o" -exec rm -v \{\} \; && find build -name "*.gcno" -exec rm -v \{\} \; && cd src && rm -rvf cluster libnptm trapping include sphere testing Makefile Makefile.bak make-bak make.inc README.md && cd .. && rm -rvf containers && cd doc && rm -rvf src && cd build/latex && rm -rvf *.tex *.out *.sty *.ind *.log *.toc *.ilg *.idx *.aux *.eps Makefile class*.pdf
 # move the installed software to /usr/local
 RUN mv /root/np-tmcode /usr/local
 
diff --git a/containers/singularity/np-tmcode-run.def b/containers/singularity/np-tmcode-run.def
index 580ee1d1e596c0baf1a980b85a0221f6392c945b..34adab72f97c5e6e25de3b4a93d34ef979cab150 100644
--- a/containers/singularity/np-tmcode-run.def
+++ b/containers/singularity/np-tmcode-run.def
@@ -27,34 +27,49 @@ Stage: np-tmcode-run-dev
 	cd /usr/local
 	rm -rf /usr/local/magma-compiled
 	rm -rf /var/lib/apt/lists/*
-	cd /usr/local/np-tmcode/src
+	cd /usr/local/np-tmcode/build
 	# repeat for every "flavour" we want to compile
 	# with magma, ilp64, mpi, openmp
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make -j
-	mv ../build/cluster/np_cluster ../build/cluster/np_cluster_magma_mpi
+	#BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe
+	CXX=mpicxx FC=gfortran ./configure --enable-static --enable-mpi --enable-ilp64 --enable-openmp --with-lapack --with-magma
+	make clean
+	make -j
+	mv cluster/np_cluster cluster/np_cluster_magma_mpi
 	# with magma, ilp64, no mpi, openmp
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 CXX=g++ FC=gfortran make -j
-	mv ../build/cluster/np_cluster ../build/cluster/np_cluster_magma_serial
+	#BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_MAGMA=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe
+	CXX=g++ FC=gfortran ./configure --enable-static --disable-mpi --enable-ilp64 --enable-openmp --with-lapack --with-magma
+	make clean
+	make -j
+	mv cluster/np_cluster cluster/np_cluster_magma_serial
 	# with lapack, ilp64, mpi, openmp
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make -j
-	mv ../build/cluster/np_cluster ../build/cluster/np_cluster_lapack_mpi
+	#BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe
+	CXX=mpicxx FC=gfortran ./configure --enable-static --enable-mpi --enable-ilp64 --enable-openmp --with-lapack --without-magma
+	make clean
+	make -j
+	mv cluster/np_cluster cluster/np_cluster_lapack_mpi
 	# with lapack, ilp64, no mpi, openmp
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 CXX=g++ FC=gfortran make -j
-	mv ../build/cluster/np_cluster ../build/cluster/np_cluster_lapack_serial
+	#BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_LAPACK=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe
+	CXX=g++ FC=gfortran ./configure --enable-static --disable-mpi --enable-ilp64 --enable-openmp --with-lapack --without-magma
+	make clean
+	make -j
+	mv cluster/np_cluster cluster/np_cluster_lapack_serial
 	# with lucin, ilp64, mpi, openmp
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make -j
-	mv ../build/cluster/np_cluster ../build/cluster/np_cluster_legacy_mpi
+	#BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 USE_MPI=1 CXX=mpicxx FC=gfortran make wipe
+	CXX=mpicxx FC=gfortran ./configure --enable-static --enable-mpi --enable-ilp64 --enable-openmp --without-lapack --without-magma
+	make clean
+	make -j
+	mv cluster/np_cluster cluster/np_cluster_legacy_mpi
 	# with lucin, ilp64, no mpi, openmp
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe
-	BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 CXX=g++ FC=gfortran make -j
-	mv ../build/cluster/np_cluster ../build/cluster/np_cluster_legacy_serial
-	make docs -j && make -C ../doc/build/latex -j
-	cd ../build/cluster
+	#BUILDDIR=../../build BUILDDIR_NPTM=../../build/libnptm LIBNPTM=../../build/libnptm/libnptm.a USE_ILP64=1 USE_OPENMP=1 CXX=g++ FC=gfortran make wipe
+	CXX=g++ FC=gfortran ./configure --enable-static --disable-mpi --enable-ilp64 --enable-openmp --without-lapack --without-magma
+	make clean
+	make -j
+	mv cluster/np_cluster cluster/np_cluster_legacy_serial
+	cd ../doc/src
+	doxygen config.dox
+	cd ../build/latex
+	make -j
+	cd ../../../build/cluster
 	# this is the default
 	ln -s np_cluster_lapack_mpi np_cluster
 
diff --git a/src/libnptm/Commons.cpp b/src/libnptm/Commons.cpp
index b030cb17962c06c328c98de255c15308b7048944..e006b0bda5488f6a1b909d4c34e3acdd2f84f4b1 100644
--- a/src/libnptm/Commons.cpp
+++ b/src/libnptm/Commons.cpp
@@ -30,6 +30,8 @@
 #include "../include/Commons.h"
 #endif
 
+#include <cstring>
+
 #ifdef USE_MPI
 #include <mpi.h>
 #endif