Minimal changes and refactoring within the HammingDistance.