Closer Align the Java and Scala versions