How to rewrite a C++ codebase successfully