Refactor to work with separate client/server