Fix for failed download handling and sql issues