Sometimes less is more. This is one of those times.
After a new application has been rushed to production, or as years pass with an established application, the source code acquires a lot of cruft. Unnecessary routines, logical branches that will never get executed, variables that aren’t used, and many other undesirable items accumulate over time.
If you had to delete the code base completely and start over from scratch, would you go about the project in the exact same way? Probably not.
Sometimes the best you can do is to trim the fat. Remove extra lines of code. Eliminate the extra variables. Refactor and simplify the code for a more obvious flow. The more you delete, the less junk there will be to cause problems later.
On the other hand, sometimes too much time is spent trying to salvage bad work. In those cases, you may have to take more drastic measures. Delete the code and start over.