Added makefile, fixed bugs