Refactored the Trie to use a custom datatype for searches, for safety.