Change element creation to first create the hierarchy with ids, then set properties