clean up a little. less setting global variables all over the place. only a couple places.