Correct the HSMM algorithm.