Possible deadlock fix?

Not easy to test deadlock conditions, but this might fix #88