Pushing futher changes

We need a trie instead of this switch-if-while mess