fix some null pointer issues