Added better handling of failed downloads.