Roll back new statistics code whic his causing memory leaks

This reverts the following commits:
  1. 38eeeeb679ba80c98047bc177da5b58a7129e67c
  2. 87695c44c91c6052487486ef5db39f15f742690d