Move code to ClassGenerator.