Gateways re-factoring