Refactoring in order to implement the stats system.