changed trie structure to use weak references