fixes to encoding