Massive refactor of setup code, now a class and stuff.