Keeping track of statistics optimized

The database and the code for keeping track of statistics has been
optimized for performance issues. Improved query speeds and the bot's
calculation of statistics for users via optimization of queries and the
database design (and patching the code accordingly).