Refactored hash decision algorithm.
More cleaning up