Changed LogSumExp to be thread safe