add defineModuleFunctions(dir) and register cs correctly