Merge pull request #2 from @samercier.

This was done via the command-line using patches. Pardon any farts. I
also edited some of the changes to make them more coherent.