Refactored the statistics handling to use more common calculations where possible. Also included initial tagging code.