Improve makefile and related scripts