Refactor to enable future implementation of loopback.