Refactor hmm related code into hmm file
Finish HMM model refactoring