(seriously though, this book has answers for you: Working Effectively with Legacy Code, by Michael Feathers)