Cleanup k item constructor

Clean up dead code introduced in test generation; remove performance bottleneck of the new rewrite algorithm.
No. I assume that this kind of user defined sort predicate does not have side conditions. But it didn't work before either.