Fix minor encoding bugs