Fixed bugs with ny>1. Could be made faster by not generating y when
y_sim >1