Extract values to global dynamic vars.
Refactor stats output.
Add simple measures for thread safety.
Use an executor for regularly emitting statistic data.