Move all download code into one file. numerous other small changes.