Change from run-state-machine function to record w/ start & stop methods. Add optional debug-fn.