Cleanup: Move the utility code to its own file.
Merge pull request #16 from rjnagal/stats

Cleanup: Move the utility code to its own file. Add header comments.