Add some necessary null checks.