Change to using object lookups rather than array lookups

This change makes the intersection O(n+m) rather than O(n*m), resulting in incredibly [significant](http://jsperf.com/array-lookup-vs-object-lookup-intersect) speed ups for large arrays.