smart proxy discovery

Can you refactor these to factory methods? Then please squash the commits, we can merge. I haven't tested yet tho.