Reorganize code for repo stats