Refactors Stats module and creates 3 modules in stats directory