Fix issues in Java code. Remove some unnecessary code.