fixes some null pointer errors