Implementing our version of Counter Barrier, credit to lkiv for his original implementation.