Stats implementation and cleanup.