adding saveJSON(), cleanup and tweaks to output/files.js