Reorganization and added some utf8 handling