Refactor code, split up between multiple files, move all globals to config module