much improved download() function, uses separate data directory