Got partway through fixing #23, though I think something a bit better than "replace all problem characters with spaces" will be called for. I also started breaking out the code into functions, so we can put in some better structure as we get everything working well.