Prevent nested synchronize calls on different nodes from affecting each other

Should prevent race conditions when calls to `synchronize` are nested.
Merge pull request #1005 from jnicklas/nested-synchronize

Prevent nested synchronize calls on different nodes from affecting each other