Refactor document.