refactor proxy.c some