Download script, some fixes and improvements