Fix for issue #2051.  Not perfect (can get into a lock in some situations) but usable.