Fixed some null pointer exception errors