Fixed some database errors