Add error handling and more options to trie_ops