fixed mutable map/foreach bugs