Change the way of handling monitoring counters to prevent double counting if a race condition occurs
Instead of resetting the current counter to zero, the new version saves it as last_counter and uses this last_counter during the next statistics update. This prevents double counting if a race condition between the data handling and the statistics publishing threads occurs.