An attempt at a faster instance lookup implementation

@garyb A slightly better approach to the slow instances problem.

Basically I use a `Map` to avoid keeping multiple copies of the same actual instance in the graph.