Encoding: A few small fixes

Things appear to be correct in all cases now