Refactor

Major cleanup/reorganization of responsibilities.