proxy: refactor to make the named functions be top-level

Cleaner code == better