Several optimizations in tick loop.