Remove unnecessary elements