Added null ptr checks.