Changes to safe_while