Added Hamming distance function.