Fix deadlock

Fix deadlock issue found by Mihai