Various bug fixes.
Add Makefile