another bunch of .decode corrections
and finally .encode output