some clean up in the encoding code