First major refactoring complete.