Lots of fixes, saving to database, restoring from database, statistics properly shown, and more