Amazon S3 support and refactoring