OnRun modification

Proper order and place for BeforeRun(), OnRun() and AfterRun()