core: utils: refine statistics collecting code