Refactored S3 APIs (thanks to @kmizu)