Misc bugfixes in makefile