Starting to really refactor this codebase