More encoding fixes