Various encoding fixes.