GUI shows organization/location attached to hostgroup when in fact it is not

I am automatically creating hostgroups and attach them to all the locations
and organizations. Every once in a while some organizations/locations don't
get attached, but in GUI they show up as "selected". Submitting the
hostgroup, without any change, fixes this.
Did any of you encountered this strange behaviour? Tried to update (REST)
the hostgroup (with a value that was already set), but didn't work like it
did from GUI. Is there another workaround?