Remove unnecessary elements.