Deadlocks and Race Conditions - fixed