Refactoring.
1. Being able to spot the point at which the cost of cleaning up convoluted and fragile code is lower than the cost of continuing to work with it. And evaluating that it’s worth the long term investment.
2. Actually being able to turn the ship around.