Great advice if you want a miserable 40 year career as a team player in mind numbing corporate work prevention departments.
Bad advice if you want anything more out of your programming career.
Horrible advice if you want to make a difference by sharing your gifts with those who need them.
You don't get that many chances to do what OP did by jumping in and making dramatic improvements.
The only reason I have ever avoided staying the hell out of legacy code was when opening that can of worms was just the wrong thing to do for everyone.
Otherwise, I got the hell in there.
Sometimes I was thanked.
Sometimes I was reprimanded.
Sometimes I was fired.
Always I learned something, usually the best learning I ever had.
(And as for getting fired, I wouldn't have changed a thing. This is actually a good thing. Better to push the limits, find out who you're dealing with, and move on quickly rather than being miserable for years without ever understanding why.)
The Best Programming Advice I Ever Got? ... Always Do the Right Thing. (Even if it takes a lifetime to figure out what that is.)