Added Java exception throwing to the JNI parts. Improved the code quality a bit.