stuffed some sense into api.factory