fixed several small bugs in automaton construction