Fixed some generation bugs