Small improvements to critical value simulation code
[ci skip]