Bugfix for setChildren, with added assertions