Make code gen script more generic