Refactoring with an eye toward performance