Start of refactor.  Fix for major bug involving calculation of the hash.

All previous versions of this software were bad!