Fix counters and locks ordering.