Fix or workaround some locking deadlocks.