Refactor add package via URL functionality, add further error checking