fix stats + refactoring