fixed foreign key issues