Clean up JNI code, add stack trace to check up on Jenkins test.