Fixes to make this work on Amazon S3 and EMR