JNI Wrapper: Some code refactoring.