Update documentation and fix a few bugs