Refactoring code and codebase