Remove two-iteration loop from ExpandGeneric
Remove two-iteration loop from expand_filename
Remove two-iteration loop from check_keyword_id