Minor refactoring on gateways