fixed some deadlocks and segfaults