Added sorting options and some fixes in cache policy.