Fix bug with exceeding trie array bounds, alter function signatures