handle undef objects

Some modifications from our codebase that handle undef objects in various places.