Add Javadoc comments and fix some flaws in documentation.