more javadocing and refactoring