s-trie major refactoring