Comparator improvements done

A few bug fixes as well.