Partial HMM refactoring