Some code has been changed (refactoring) and performance improvement in calc_statistics

calc_statistics employing local variables and then using
InterlockedExchangeAdd reduces the amount of atomic operations and
therefore improves the concurrency of the application.