Various fixes to the loops.