Refactoring a bunch of stuff