reworked download.js to clone the document object; added stringify() methods to state.js and config.js