You can use reparent() to change the flags. That should work.