Minor refactorings to the Java code