Updated Stats box to support categories/discussions view. Also reorganized code to reduce complexity.