Fixed a few null pointer issues.