Fixed #887: Choose thread affinities more cleverly