KIF updates, and merging Pei changes (except CompoundTerm.compareTo which breaks CompoundTermTest)