fixed deadlocks and seems to be stable now