Fixed issues with QD2QD distance