Move scope generation into the main generator