Remove document.write, fix DOMParser for Safari, fix shared state in Firefox