Critical fix in new ray generation