Fix handling of null/undefined