added more support for modifying the parent when adding a child