Add Finite State Machine simulator.
Floated nested functions up. Wrote a schedule and reschedule function.
Added FSM and rewrote code.