A, hopfully, proper threading fix