Split out download code.