Optimize session loop.