Add support for proxies (mostly done by @sbrunner)