Fix some null pointer exceptions
Merge remote-tracking branch 'origin/master'