JNI Wrapper: Added more functions and better error handling.