Improve stanza updating algorithm

It no longer depends on the order of fields.