Improve trie creation efficiency