Changes to removeElement, fixed retrieveAttributes, added destroyAttributes.