Updated Engine's Finite state machine to run on a state stack.