New sync code with S3 support