Fixed HMM-related bugs.