fix some double encoding issues

Numerous "FIXME" items documented. But because of the confusing nature
of the existing code, someone with better familiarity of how things are
supposed to work needs to address them.