And these can also be explained by unit tests .. you keep the old unit tests and rewrite everything so those tests pass. Sometimes that means getting some of the same weird quirks or gotchas, but hopefully refactored so they are all in one place and clearly documented.