gen2_code revamped for class stucture