common: major cleanup and commenting; move GatewayCollection into me, since it is not used elsewhere