 
     layer->filter_weights = nullptr;
     layer->filter_bias = nullptr;
+
+    layer->input_size = (size_t*) malloc(3*sizeof(size_t));
+    layer->output_size = (size_t*) malloc(3*sizeof(size_t));
+    layer->filter_size = (size_t*) malloc(2*sizeof(size_t));
+    layer->strides = (size_t*) malloc(2*sizeof(size_t));
+    layer->pad = (long int*) malloc(2*sizeof(long int));
+
+    for(size_t i = 0; i < 3; i++)
+    {
+        layer->output_size[i] = fp->layers[fp->numlayers - 1]->output_size[i];
+        layer->input_size[i] = fp->layers[fp->numlayers - 1]->output_size[i];
+    }
+
+    layer->filter_size[0] = 1;
+    layer->filter_size[1] = 1;
+
+    layer->strides[0] = 1;
+    layer->strides[1] = 1;
+
+    layer->pad[0] = 0;
+    layer->pad[1] = 0;
+
+    fp->layers[fp->numlayers] = layer;
+
+    fp->numlayers++;
+}
+
+
+void handle_residual_layer(elina_manager_t* man, elina_abstract0_t* element, const size_t num_neurons, size_t* predecessors)
+{
+	fppoly_t* fp = fppoly_of_abstract0(element);
+	res_add_layer(fp, num_neurons, RESIDUAL, NONE);
+	fp->layers[fp->numlayers - 1]->predecessors = predecessors;
+}
+
+
+void free_layer(layer_t* layer)
+{
+    cudaFree(layer->coeffs);
+    cudaFree(layer->csts);
+
+    layer->coeffs = nullptr;
+    layer->csts = nullptr;
+
+    cudaFree(layer->lb_array);
+    cudaFree(layer->ub_array);
+
+    layer->lb_array = nullptr;
+    layer->ub_array = nullptr;
+
+    cudaFree(layer->filter_weights);
+    cudaFree(layer->filter_bias);
+
+    layer->filter_weights = nullptr;
+    layer->filter_bias = nullptr;
+
+    free(layer->input_size);
+    free(layer->output_size);
+    free(layer->filter_size);
+    free(layer->strides);
+    free(layer->pad);
 
     layer->input_size = nullptr;
     layer->output_size = nullptr;

}


void layer_create_sparse_exprs(fppoly_t* const fp, const double* filter_weights, const double* filter_bias,
                               const size_t* input_size, const size_t* filter_size, const size_t num_filters, const size_t* strides,
                               const bool is_valid_padding, const bool has_bias)
{
    const size_t num_pixels = input_size[0]*input_size[1]*input_size[2];


    fppoly_t* const fp = fppoly_of_abstract0(element);
    fp->layers = (layer_t**) malloc(2000*sizeof(layer_t*));

    layer_create_sparse_exprs(fp, filter_weights, filter_bias, input_size, filter_size, num_filters, strides, is_valid_padding, has_bias, RELU);

    fp->layers[fp->numlayers - 1]->predecessors = predecessors;

