Refactor stats data

@emord 

please review my changes in c8bfc71, 59edc84, and ea4771f to make sure I got things right