fix invalid p element, update cofi_cost [ci skip]