Many small fixes to Java FFI

- Clean up code
- On the way to fix #437
- Plug leak of JNI local refs