Fix problems with document.