Fixed a ton of database related stuff