Iterate more carefully over item vector when smashing items in it.

Use nice modern iteration style while I'm at it. 
Should fix #7727