restructuring done except for some compiler errors (how to make a
LossyFiniteAutomaton from a VarId?)