Some more intelligence added in the Makefile and script