Fixed Makefile (ty Edison) and cleaned up code