Refactor response handling code out into separate class/ files