Iterate the removal loop backwards to actually remove all the unneeded tokens.

This fixes bug 2849.