Fix bug where transitions would exist to deleted states

Fix bug where a finished state machine would contain transitions
to a state that had been deleted.