ConcurrentModificationException Fix for Ticket 368

ConcurrentModificationException are bound to happen when you're
iterating over a hashmap (or anything related) and while you iterate
over it you are adding to it or removing from it. To avoid this, just
create a temporary copy of it and iterate over the temporary one and
make changes to the real one.