Eliminate redundant states in finite state machine