Implement GMHMM; fix bugs in base and discrete