fix the order of marginals &c