When removing element, remove it also from group; Remove group if it is empty.