refactoring of computeStats
easier modification of number of past values computed
Code cleanup