Client gateway refactor + cleanup