updated flag handlers, specifically empty, to handle undefined function returns and more