Fix bugs in Automaton discovered by Jeff