Refactor req/rep code into exchange package