With bad code it’s often almost impossible to improve the functionality or correctness or performance of the code, without first rewriting parts of it.