Fix generation algorithm.