Check for null and clean up