Bug fixes and tmhmm