General cleanup, start thinking about implementing non-deterministic automaton