Refactor stats stuff