more wip work on hooked functions and jnienv

Sending now to avoid huge pull req later.