Added exception safety to download functions