Refactor the entire codebase