cleaner extracted code, better makefile