PR from GCI staging_done branch

Had to do some conflict resolution as well. :|
SET NULL is illegal in a link table. Must be CASCADE.