Fix thread count leak