Speed improvement. Replace list with hashset.

The improvement doesn't alter the logic too much. 
Seems possible to get a larger speed improvement by understanding & altering the logic more.
For a page with 1800 elements takes 20 seconds to load the full page.
For 600 elements takes 7 seconds to load a full page instead of 15 seconds.