Fix some encosding related issues