Made some changes to deal with character encoding problems.