javadocing/commenting and some light refactoring.