More work done on JNI stuff.
Cleaned up some code.