Bug fixes and trie tests