Fixed DB bugs