refactor s3 and image cleanup helpers