If you have the <i>option</i> of leaving it alone, then you probably should, however if you&#x27;ve already got to work on the messy part anyway, and if the code is messy to the point of being difficult to read, then you might be <i>reducing</i> the chance of introducing new bugs if the first thing you do is refactor the lot such that you don&#x27;t cringe just looking at it.<p>I&#x27;m talking about cleaning up <i>the code</i> though, not the <i>logic</i> - refactor really isn&#x27;t even the right word. Poor choices for variable names, misleading or just plain wrong comments, inconsistent use of whitespace, etc etc.<p>And even this you should only do if you really think it&#x27;s necessary, since it will make it very difficult to use diff to suss out what your <i>actual</i> changes to the area were after you&#x27;re done. Still, there is a time and a place for it.