Fix bugs with global variables not sticking.