Some download code and fixes