Neaten up S3 caching script