Fix ref iteration behavior