In ReFactoring you clean up the code, sometimes doing radical changes, without changing the overall behaviour or functionality. For instance you may combine code from two methods into one, move instance variables around, or remove code no longer needed.
In ExtremeProgramming you can refactor mercilessly because you have written all the UnitTests and AcceptanceTests upfront. See RefactoringImprovingTheDesignOfExistingCode.
For more information on ReFactoring, see Martin Fowler’s website: http://martinfowler.com/ He also has a bliki (a cross between a weblog and a wiki) http://martinfowler.com/bliki/ His book “Refactoring: Improving the Design of Existing Code” ( http://martinfowler.com/books.html#refactoring) is highly regarded. Etymology of Refactoring ,(September 10, 2003) http://martinfowler.com/bliki/EtymologyOfRefactoring.html