Fixed some database problems