Merge Makefile rewrite into master