 
     CascadedMetadata* metadata = (CascadedMetadata*)metadata_ptr;
 
-    nvcompIntConfig_t c = generateConfig(metadata);
+    std::unique_ptr<nvcompIntConfig_t> c = generateConfig(metadata);
 
     // first - optimize the plan
-    c.optimizeLayers();
+    c->optimizeLayers();
     // assign pointers - at this point the nodes map is set
-    for (auto it = c.layers.begin(); it != c.layers.end(); it++) {
-      it->vals = &c.nodes[it->valId];
-      it->output = &c.nodes[it->outputId];
-      if (it->runId >= 0) {
-        it->runs = &c.nodes[it->runId];
+    for (auto& layer : c->layers) {
+      layer.vals = &c->nodes[layer.valId];
+      layer.output = &c->nodes[layer.outputId];
+      if (layer.runId >= 0) {
+        layer.runs = &c->nodes[layer.runId];
       }
     }
 
     // Return the required temp storage size
-    *temp_bytes = c.getWorkspaceBytes();
+    *temp_bytes = c->getWorkspaceBytes();
   } catch (const std::exception& e) {
     return Check::exception_to_error(
         e, "nvcompCascadedDecompressGetTempSize()");

  *handle = id;
  nvcompIntHandle_t& h = handles[id];

  h.config = config;
  h.stream = stream;

  h.workspaceBytes = workspaceBytes;

  // initialize config
  const nvcompType_t type = metadata->getValueType();

  std::unique_ptr<nvcompIntConfig_t> config(new nvcompIntConfig_t);
  config->outputId = vals_id;
  config->outputType = type;
  config->maxOutputSize = metadata->getUncompressedSize();

  const nvcompType_t runType
      = selectRunsType(metadata->getNumUncompressedElements());

  const size_t maxSegmentSize = metadata->getUncompressedSize();

  config->nodes[0].length = metadata->getNumUncompressedElements();

  // A step can be RLE+Delta, RLE, or Delta, with final outputs conditionally
  // having bit packing applied
