lazily evaluate sort of KItem
fix bug in cloning
fix stray change
Merge pull request #1271 from dwightguth/kmachine

lazily evaluate sort of KItem