mostly javadoc and minor refactorings