Move download code to mod.js