Some more refactoring

Use iterators instead of C-style counters in for() loops.  Replace
string indexing with array search.