Fixed open and close document.