Stash and restore globals.