when I had to maintain someone's crap that was written like that.

But you're right, you have to go through it carefully, analyzing all the pieces and figuring out what you can "safely" extract. It takes months (or years if it's big). But the last time I did one like that was 1997, before Internet time.