Refactored a lot of the codebase for later.