The code being a mess usually calls for refactoring not rewriting. As I understand it, the showstopper that made a rewrite necessary was that they had made the mistake (understandable since they were in a desperate hurry but mistake nonetheless) of using proprietary libraries.
Technical debt can accrue to the point where a piece of software is "bankrupt." Any successful refactoring amounts to extracting a subset and redoing everything else, which can practically amount to a rewrite.