fix bugs around matching (... p <ellipsis> ...) pattern