Added main loop and fixed Makefile