Updated to work with new v3 pattern and trie packages.