Added null checks.