Some encoding fixes