Modulize code. Separate out into main, trie and trie node.