Added leaderboards and stats with MySQL and SQLite support.

Fixed some issues with previous pull request.