Fixed some null pointer Errors