Move main generator to separate file.