Fix a bunch of NullPointerExceptions
Seems to be stable now.