Merge pull request #7 from tsandras/tristan2

Fix bug with state machine