Refactor download logic for plugins