Minor refactorings and additional Javadoc