Minor bugfixes and refactoring of Makefile, with more documentation.