Improve handling of null case.