Improved error handling and addressed bug with spaces in S3 files.