Added some explanation, and made some improvements after more thorough
testing.