Cleaned up 'undefined' handling