work done on JNI helper funcs (not compiling ATM)