Merge fix

concurrency issue in merge.

Bug report #1867.

I'm not sure if the wrong guard in merge contributed to this bug or not.