Fix null pointer issues.