fixed some foreign key problems.