Tweaks and cleanup.

Use HasPrefix in lieu of Contains when matching things.  Minor
code cleanup and tweaks.