Cleanups to foreach workaround.