Added a proper ranking system, now also saved in the database.

Title says it all, there's still some more to do, but for the most part it's done.