Fix for crash when passing undefined

Fix for crash in 2 places when inadvertently passing undefined.