Refactoring of ancient codebase