Further fixes to UTF-8 handling