Turn some 'for' loops into 'while' loops.