Nontrivial because yreference is inside the gain loop. Might want to make a separate implementation or something.