Fixed some issues with duplicates. Added temp cache.