completed Automaton logic, but still needs twitching; some tests still fail