Added implementation of universal state machine