code refactor, progress towards stat extraction