gateway: introduce and use removeGatewayFromList function