Fixed race condition causing dicionary size changedduring iteration  RuntimeError