Fixed deadlocks in background processing