In the end, we are problem solvers first, programmers second.
If it's just bad code, you can solve it by just dealing with it as is whilst slowly improving it.