Overall cleanup, ditched the last global variable