Various tweaks & bug fixes, mostly for encoding.
Merge branch 'bleeding-jumbo' into memdbg

* bleeding-jumbo:
  Various tweaks & bug fixes, mostly for encoding.