Bug fix: don't change invalid elements.