Fix bug where dictionary encoding failed