Move batch sorting to factories