improved the hamming distance based on a comment by Aric Hagberg.