fix CHECK condition and dump stats to file so the stats dump doesn't hide the error message