Adding extra check for gains soln, plus debugging step