fixed deadlocks , double free