JNI fixes