Consistent use of ch to avoid indexing string's character array more than once.

Made the code that indexes through the string character by character actually only do the array dereference once and used consistent formatting of switch.