Bugfix: don't change list while iterating through it.