Redid stuff to allow arbitrary Q_ij in a nice way