Rewrote Makefile, minor code fixes due to more pedantic warnings