Fix handling of null objects