Fixed a few nullpointerexceptions.