Fixed some null pointer exceptions