refactor clsource generation