Client gateway refactor