Changes to database interaction

Made changes with the way things are read and added to the database.
Also, added in culling of some old data, and forced appropriate changes
to ratings when removing old data.