Refactor messaging setup