Add javadoc and fix inconsistencies.