Small improvements on loops