Legacy code—warts and all—isn't such a bad thing.
If it's built well, and maintained well, it probably takes care of the hundreds/thousands of edge cases with which your beautifully-rewritten new codebase doesn't yet cope.
Unless it's not well-documented (or self-documented), or incompatible with modern systems, it's often a better idea to refactor and clean up old code than to scrap a system entirely and rewrite from scratch.
Image from Thinking Through.