Simplify some loops.