Fixed some null checks