Fixed a bunch of database stuff.