more cleanup; fix bug in Java version