Minor refactoring and Javadoc additions