Major optimization patch

Optimize the state machine clocking with full prediction to next event
to JIT to.