refactoring a lot of stuff. no more global variables