Refactoring documents