Add graceful stats integration.

Restructure the code a bit such that modules can be added more easily
in the future. Add a graceful stats module. Probably needs more error
checking, to be honest, but it does seem to work, I think?