Codebase refactor