NullPointer fixes

Trying to fix a few nullpointers from the java interop.