Made generic the convert to UTF-8 script, also added some comments.