Improve threading performance