More refactoring all over the place.