Handle barriers on Main and Background queues
Fix deadlocking on Main + test
Improve deadlock prevention + tests