Small improvements to handling of attribute and remove elements.