Refactor in preparation for adding the server