Fix various db errors.