Initial download functionality. Needs some refinement and cleanup.