|Which is correct?
The code __________________________.
Explanation: Badly is taken to modify whatever word it’s closest to. In this example, if you say the code needs to be rewritten badly, that means it needs to be rewritten and that the rewrite must be a bad one.
On the other hand, by placing badly right next to needs, the reader understands that the need for a rewrite is extreme. (It is likely to be understood that an improvement over the original is desired.)