Added code for training hmms