Fixed overflow issue with boltzmann_factor = exp(-diff/T)