implement DFA class and associated serialization classes