Added checks for null.