fixes the clean up references to missing elements