move to separate TrieBuilder, cleanup the creation logic