similarity calculation, small fixes