Refactor StatsFromLog class; add comments; remove duplicate code