restore PSC file generation. simplify code