Refactor proxy creation in router