Xcode 6
Refactor and fix issues with determining and caching entity sort key.