Converted more code to Java.