Elaborate the construction of state machine; add states diagram.