Fix unselect bug on edit
Add feature that update foreign keys