Implement mirror function for StateMachine and fix a bug in DOT export