Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure. – MartinFowler
Refactoring is typically done in small steps. After each small step, you're left with a working system that's functionally unchanged. Practitioners typically interleave bug fixes and feature additions between these steps. So refactoring doesn't preclude changing functionality, it just says that it's a different activity from rearranging code.