Changed occurences of != None to is not None as suggested by code review.