How do you handle refactoring and legacy code?

How do you handle refactoring and legacy code?