updted Makefile, cleaned up code