Added -v flag and removed unnecessary lock for loop counting.