Changing encoding cost to an incremental thing using state handles.
Wrote much better code for coding cost that lets you do incremental updates, and only costs a lot of string copying on restarts