Improved speed of purge by using unordered_set