Switch from using replace() to iterating over the string.
Breaking out a few helper functions.
Tweak to README.md