cleanup proxy code a bit