Add support for global stats.

Closes #6.