Simplify and cleanup proxy creation

In the process of cleaning up the suggested changes in #22, I took the liberty of simplifying the proxy construction somewhat, see 9d31328780eb3a1f25b866fb78244353a7e03946 for details.

While doing so, I made some other minor improvements. I could make separate pull requests for them if you prefer, but I've tried to make the individual commits small enough whit reasonable commit messages.