(#2477) - use a Map and Set instead of an object 

in various places where it would be a speed up/ prevents errors