clean elements and tree