Move tick loop changes to own patch with a few optimizations.