Well, yeah - that never happens. You do tech debt cleanup "as you go". Slip in a few tickets to cleanup specific things and have a policy to update code that is touched when adding features / fixing bugs.
It needs to be a continual cleaning process. That's why it's called debt - the longer you let it go un-paid the harder it is to do.