diff --git a/src/cats/stats/grid_stats.c b/src/cats/stats/grid_stats.c
index 49b48a84a0af3a3414eb188467c2a87652810f0f..d018b5e83c5a32c18e97a1d43909e281c0da6dac 100644
--- a/src/cats/stats/grid_stats.c
+++ b/src/cats/stats/grid_stats.c
@@ -144,8 +144,10 @@ void consolidate_thread_stats(struct cats_grid *grid, struct cats_configuration
                                 g->stats.stats[stat_idx] += threads[i].stats[class].stats[stat_idx];
                         }
 
-                        for (int64_t j = 0; j < threads[i].stats->custom_stat_count; j++){
-                                g->stats.custom_stats[j] += threads[i].stats[class].custom_stats[j];
+                        if (g->stats.custom_stats) {
+                                for (int64_t j = 0; j < threads[i].stats->custom_stat_count; j++){
+                                        g->stats.custom_stats[j] += threads[i].stats[class].custom_stats[j];
+                                }
                         }
                 }
         }
diff --git a/src/cats/stats/statistics.c b/src/cats/stats/statistics.c
index 73e4c208f9c714d3a74a8c1c19b22a41849012b1..d853989677488f82f2422a2950db187cf60d9b28 100644
--- a/src/cats/stats/statistics.c
+++ b/src/cats/stats/statistics.c
@@ -59,8 +59,10 @@ void zero_statistics_stats(struct statistics *stats)
                 stats->stats[i] = 0;
         }
 
-        for (int64_t i = 0; i < stats->custom_stat_count; i++) {
-                stats->custom_stats[i] = 0;
+        if (stats->custom_stats != NULL) {
+                for (int64_t i = 0; i < stats->custom_stat_count; i++) {
+                        stats->custom_stats[i] = 0;
+                }
         }
 
 }
@@ -83,6 +85,7 @@ void cleanup_statistics(struct statistics *stats)
 {
         if (stats->stats_header) free_string_array(&stats->stats_header);
         free(stats->custom_stats);
+        stats->custom_stats = NULL;
 }