Refactor code to download urls in batches.