More refactoring and stuff.