Refactor out how requests are handled to server