Fixed some deadlocks.

11 files changed