Added a counter for multithreading purpose.