Some small improvements for the Java implementation