Minor loop improvements