Encoding fixes