Long overdue commit including improvements to some counting statistics functions and some new modules