Loop optimization.