Add some null checks.
Remove an unncessary import.