diff --git a/fuse_sideload/fuse_sideload.cpp b/fuse_sideload/fuse_sideload.cpp
index 8fa8ad4..3d94803 100644
--- a/fuse_sideload/fuse_sideload.cpp
+++ b/fuse_sideload/fuse_sideload.cpp
@@ -45,9 +45,8 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#include <limits.h>
-#include "fuse.h"
-#include <pthread.h>
+#include <limits.h>  // PATH_MAX
+#include <linux/fuse.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -58,19 +57,13 @@
 #include <sys/uio.h>
 #include <unistd.h>
 
-#ifdef USE_MINCRYPT
-#include "mincrypt/sha256.h"
-#define  SHA256_DIGEST_LENGTH SHA256_DIGEST_SIZE
-#else
-#include <openssl/sha.h>
-#endif
-
 #include <array>
 #include <string>
 #include <vector>
 
-//#include <android-base/stringprintf.h>
-//#include <android-base/unique_fd.h>
+#include <android-base/stringprintf.h>
+#include <android-base/unique_fd.h>
+#include <openssl/sha.h>
 
 static constexpr uint64_t PACKAGE_FILE_ID = FUSE_ROOT_ID + 1;
 static constexpr uint64_t EXIT_FLAG_ID = FUSE_ROOT_ID + 2;
@@ -80,12 +73,8 @@
 
 using SHA256Digest = std::array<uint8_t, SHA256_DIGEST_LENGTH>;
 
-#ifndef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
 struct fuse_data {
-  int ffd;  // file descriptor for the fuse socket
+  android::base::unique_fd ffd;  // file descriptor for the fuse socket
 
   FuseDataProvider* provider;  // Provider of the source data.
 
@@ -102,8 +91,8 @@
 
   uint8_t* extra_block;  // another block of storage for reads that span two blocks
 
-  uint8_t* hashes;        // SHA-256 hash of each block (all zeros
-                          // if block hasn't been read yet)
+  std::vector<SHA256Digest>
+      hashes;  // SHA-256 hash of each block (all zeros if block hasn't been read yet)
 };
 
 static void fuse_reply(const fuse_data* fd, uint64_t unique, const void* data, size_t len) {
@@ -162,7 +151,7 @@
 
 static void fill_attr(fuse_attr* attr, const fuse_data* fd, uint64_t nodeid, uint64_t size,
                       uint32_t mode) {
-  memset(attr, 0, sizeof(*attr));
+  *attr = {};
   attr->nlink = 1;
   attr->uid = fd->uid;
   attr->gid = fd->gid;
@@ -175,8 +164,7 @@
 }
 
 static int handle_getattr(void* /* data */, const fuse_data* fd, const fuse_in_header* hdr) {
-  struct fuse_attr_out out;
-  memset(&out, 0, sizeof(out));
+  fuse_attr_out out = {};
   out.attr_valid = 10;
 
   if (hdr->nodeid == FUSE_ROOT_ID) {
@@ -196,8 +184,7 @@
 static int handle_lookup(void* data, const fuse_data* fd, const fuse_in_header* hdr) {
   if (data == nullptr) return -ENOENT;
 
-  struct fuse_entry_out out;
-  memset(&out, 0, sizeof(out));
+  fuse_entry_out out = {};
   out.entry_valid = 10;
   out.attr_valid = 10;
 
@@ -222,8 +209,7 @@
   if (hdr->nodeid == EXIT_FLAG_ID) return -EPERM;
   if (hdr->nodeid != PACKAGE_FILE_ID) return -ENOENT;
 
-  struct fuse_open_out out;
-  memset(&out, 0, sizeof(out));
+  fuse_open_out out = {};
   out.fh = 10;  // an arbitrary number; we always use the same handle
   fuse_reply(fd, hdr->unique, &out, sizeof(out));
   return NO_STATUS;
@@ -271,26 +257,22 @@
   //   time we've read this block).
   // - Otherwise, return -EINVAL for the read.
 
-  uint8_t hash[SHA256_DIGEST_LENGTH];
-#ifdef USE_MINCRYPT
-  SHA256_hash(fd->block_data, fd->block_size, hash);
-#else
-  SHA256(fd->block_data, fd->block_size, hash);
-#endif
-  uint8_t* blockhash = fd->hashes + block * SHA256_DIGEST_LENGTH;
-  if (memcmp(hash, blockhash, SHA256_DIGEST_LENGTH) == 0) {
+  SHA256Digest hash;
+  SHA256(fd->block_data, fd->block_size, hash.data());
+
+  const SHA256Digest& blockhash = fd->hashes[block];
+  if (hash == blockhash) {
     return 0;
   }
 
-  int i;
-  for (i = 0; i < SHA256_DIGEST_LENGTH; ++i) {
-    if (blockhash[i] != 0) {
+  for (uint8_t i : blockhash) {
+    if (i != 0) {
       fd->curr_block = -1;
       return -EIO;
     }
   }
 
-  memcpy(blockhash, hash, SHA256_DIGEST_LENGTH);
+  fd->hashes[block] = hash;
   return 0;
 }
 
@@ -377,14 +359,8 @@
     return -1;
   }
 
-<<<<<<< HEAD:fuse_sideload.cpp
-  fuse_data fd;
-  memset(&fd, 0, sizeof(fd));
-  fd.vtab = vtab;
-=======
   fuse_data fd = {};
   fd.provider = provider.get();
->>>>>>> android-10.0.0_r25:fuse_sideload/fuse_sideload.cpp
   fd.file_size = file_size;
   fd.block_size = block_size;
   fd.file_blocks = (file_size == 0) ? 0 : (((file_size - 1) / block_size) + 1);
@@ -396,14 +372,8 @@
     goto done;
   }
 
-  fd.hashes = (uint8_t*)calloc(fd.file_blocks, SHA256_DIGEST_LENGTH);
-  if (fd.hashes == NULL) {
-    fprintf(stderr, "failed to allocate %d bites for hashes\n",
-            fd.file_blocks * SHA256_DIGEST_LENGTH);
-    result = -1;
-    goto done;
-  }
-
+  // All hashes will be zero-initialized.
+  fd.hashes.resize(fd.file_blocks);
   fd.uid = getuid();
   fd.gid = getgid();
 
@@ -421,28 +391,21 @@
     goto done;
   }
 
-<<<<<<< HEAD:fuse_sideload.cpp
-  fd.ffd = open("/dev/fuse", O_RDWR);
-  if (!fd.ffd) {
-=======
   fd.ffd.reset(open("/dev/fuse", O_RDWR));
   if (fd.ffd == -1) {
->>>>>>> android-10.0.0_r25:fuse_sideload/fuse_sideload.cpp
     perror("open /dev/fuse");
     result = -1;
     goto done;
   }
 
   {
-  char opts[256];
-  snprintf(opts, sizeof(opts),
-          ("fd=%d,user_id=%d,group_id=%d,max_read=%u,"
-           "allow_other,rootmode=040000"),
-           fd.ffd, fd.uid, fd.gid, block_size);
+    std::string opts = android::base::StringPrintf(
+        "fd=%d,user_id=%d,group_id=%d,max_read=%u,allow_other,rootmode=040000", fd.ffd.get(),
+        fd.uid, fd.gid, block_size);
 
-  result = mount("/dev/fuse", FUSE_SIDELOAD_HOST_MOUNTPOINT, "fuse",
-                 MS_NOSUID | MS_NODEV | MS_RDONLY | MS_NOEXEC, opts);
-  if (result < 0) {
+    result = mount("/dev/fuse", mount_point, "fuse", MS_NOSUID | MS_NODEV | MS_RDONLY | MS_NOEXEC,
+                   opts.c_str());
+    if (result == -1) {
       perror("mount");
       goto done;
     }
@@ -530,9 +493,3 @@
 
   return result;
 }
-
-extern "C" int run_old_fuse_sideload(const struct provider_vtab& vtab, void* cookie __unused,
-                      uint64_t file_size, uint32_t block_size)
-{
-    return run_fuse_sideload(vtab, file_size, block_size, FUSE_SIDELOAD_HOST_MOUNTPOINT);
-}
