Fix download issues, refactor