Many improvements, notably for better character encoding