Fixed a few DB bugs