Refactor 'cmap' generation