major reorganization. separate pattern substitution functions from the mappings for languages and selectors.