Improved stats

This functionality adds new "stats" tool. It should have console and web interfaces.