Refactor in preparation for chat server infrastructure