Bug fix: Needed to swap indices to compute correct Xij.