Implement queued downloading, refactoring code