 }
 
 
-// TODO: Try to load values from aux-array only once and use them multiple times!
 __global__
-void coeffs_from_previous_layer_conv(const float_type* __restrict__ expr_inf_coeff, const float_type* __restrict__ expr_sup_coeff, float_type* __restrict__ res_inf_coeff, float_type* __restrict__ res_sup_coeff, const float_type* __restrict__ aux_coeffs, const size_t num_out_neurons_last_layer, const size_t output_size_x, const size_t output_size_y, const size_t output_size_z, const size_t input_size_x, const size_t input_size_y, const size_t input_size_z)
+void coeffs_from_previous_layer_conv(const float_type* __restrict__ expr_inf_coeff, const float_type* __restrict__ expr_sup_coeff, float_type* __restrict__ res_inf_coeff, float_type* __restrict__ res_sup_coeff, const float_type* __restrict__ aux_coeffs, const size_t output_size_x, const size_t output_size_y, const size_t output_size_z, const size_t input_size_x, const size_t input_size_y, const size_t input_size_z, const size_t filter_size_x, const size_t filter_size_y, const size_t stride_x, const size_t stride_y, const size_t pad_x, const size_t pad_y)
 {
     const size_t n = blockIdx.x;
 
-    for(size_t inp_x = 0; inp_x < input_size_x; inp_x++)
-    {
-        for(size_t inp_y = 0; inp_y < input_size_y; inp_y++)
-        {
-            for(size_t inp_z = 0; inp_z < input_size_z; inp_z++)
-            {
-                const size_t j = inp_x*input_size_y*input_size_z + inp_y*input_size_z + inp_z;
-                const size_t b = n*input_size_x*input_size_y*input_size_z + j;
-
-                float_type inf_coeff = 0;
-                float_type sup_coeff = 0;
-
-                float_type tmp1, tmp2;
-                float_type maxRes, maxMul;
-
-                for(size_t out_x = 0; out_x < output_size_x; out_x++)
+    float_type tmp1, tmp2;
+    float_type maxRes, maxMul;
+
+    for(size_t out_x = 0; out_x < output_size_x; out_x++)
+    {
+        for(size_t out_y = 0; out_y < output_size_y; out_y++)
+        {
+            for(size_t out_z = 0; out_z < output_size_z; out_z++)
+            {
+                const size_t i = out_x*output_size_y*output_size_z + out_y*output_size_z + out_z;
+
+                const size_t a = n*output_size_x*output_size_y*output_size_z + i;
+
+                for(size_t inp_x = 0; inp_x < input_size_x; inp_x++)
                 {
-                    for(size_t out_y = 0; out_y < output_size_y; out_y++)
+                    for(size_t inp_y = 0; inp_y < input_size_y; inp_y++)
                     {
-                        for(size_t out_z = 0; out_z < output_size_z; out_z++)
+                        for(size_t inp_z = 0; inp_z < input_size_z; inp_z++)
                         {
-                            const size_t i = out_x*output_size_y*output_size_z + out_y*output_size_z + out_z;
-
-                            size_t a = n*output_size_x*output_size_y*output_size_z + i;
-                            size_t c = i*input_size_x*input_size_y*input_size_z + j;
+                            const size_t j = inp_x*input_size_y*input_size_z + inp_y*input_size_z + inp_z;
+
+                            const size_t b = n*input_size_x*input_size_y*input_size_z + j;
+                            const size_t c = i*input_size_x*input_size_y*input_size_z + j;
 
                             const float_type prev_inf_coeff = expr_inf_coeff[a];
                             const float_type prev_sup_coeff = expr_sup_coeff[a];

        cudaMalloc((void**) &linf_coeff_tmp, num_out_neurons_last_layer*num_in_neurons_current_layer*sizeof(float_type));
        cudaMalloc((void**) &lsup_coeff_tmp, num_out_neurons_last_layer*num_in_neurons_current_layer*sizeof(float_type));

        if(fp->layers[k]->type == CONV)
        {
            coeffs_from_previous_layer_conv<<<num_out_neurons_last_layer, 1>>>(linf_coeff, lsup_coeff, linf_coeff_tmp, lsup_coeff_tmp, aux_coeffs, num_out_neurons_last_layer, fp->layers[k]->output_size[0], fp->layers[k]->output_size[1], fp->layers[k]->output_size[2], fp->layers[k]->input_size[0], fp->layers[k]->input_size[1], fp->layers[k]->input_size[2]);

            csts_from_previous_layer_conv<<<num_out_neurons_last_layer, 1>>>(linf_coeff, lsup_coeff, linf_cst, lsup_cst, linf_cst_tmp, lsup_cst_tmp, fp->layers[k]->filter_bias, num_out_neurons_last_layer, fp->layers[k]->output_size[0], fp->layers[k]->output_size[1], fp->layers[k]->output_size[2]);
        }
        else
        {
            coeffs_from_previous_layer<<<num_blocks_linear, num_threads>>>(linf_coeff, lsup_coeff, linf_coeff_tmp, lsup_coeff_tmp, aux_coeffs, num_out_neurons_last_layer, num_out_neurons_current_layer, num_in_neurons_current_layer);

            csts_from_previous_layer<<<num_out_neurons_last_layer, 1>>>(linf_coeff, lsup_coeff, linf_cst, lsup_cst, linf_cst_tmp, lsup_cst_tmp, aux_csts, num_out_neurons_last_layer, num_out_neurons_current_layer);
        }

                    continue;
                }

                if(out_x == 0 && out_y == 0 && out_z == 0)
                printf("%lu ", mat_y);

                //if(out_x == 1 && out_y == 1 && out_z == 0)
                //printf("%lu ", mat_y);

                const size_t filter_index = out_z*filter_size_x*filter_size_y*input_size_z + x_shift*filter_size_y*input_size_z + y_shift*input_size_z + inp_z;
                dense_coeff[mat_x*num_pixels + mat_y] = filter_weights[filter_index];
            }
