f315f08dc3
closes PR 13435 Also cleaned up one more threading problem (this one was probably innocuous, but it is hard to be sure and the rewrite is easier to see that it isn't problematic)