fix periodic_exact_match

There was a big bug in it previously
fix output in connect_min and find_transition_state