Update documentation and fix some bugs I saw while writing it.