mini forEach() and indexOf() replacements and minor cleanup of other replacements