Updates error messages and fixed foreign key checks