Refactor message router.