Simplified inital construction of the automaton.  Updated comments.