         if (cudaFree(pomdp->d_pi) != cudaSuccess) {
             fprintf(stderr, "Error[pomdp_pbvi_uninitialize_gpu]: %s",
                     "Failed to allocate device-side memory for the pi (the policy).");
+            result = NOVA_ERROR_DEVICE_FREE;
         }
     }
     pomdp->d_pi = nullptr;

        if (cudaFree(pomdp->d_alphaBA) != cudaSuccess) {
            fprintf(stderr, "Error[pomdp_pbvi_uninitialize_gpu]: %s",
                    "Failed to allocate device-side memory for alphaBA (alpha-vector collection).");
        }
    }
    pomdp->d_alphaBA = nullptr;

    return NOVA_SUCCESS;
}



    if (result != NOVA_SUCCESS) {
        return result;
    }

    result = pomdp_pbvi_execute_gpu(pomdp, numThreads, Gamma, pi);
    if (result != NOVA_SUCCESS) {
