More robust handling of null and undefined.