Fix thread lock and improve mating probability

See title.