Fix hidden mode sequence inference algorithm. Add file containing demo functions.