massive gateway refactoring