Fixing foreign key references.