Bug fixes and added Makefile