Trie fixes

The chunk fix is cherry picked from @graydon's `gc` branch.