Fix bugs in makefile, logging