Factor out common remote collection-related code