Fix S3/NPE issues from upstream merge.