Indroduced a state object and Workflow events. Refactored and organised code for discoverability.