Fixed some nullpointer errors.