Code cleanup and UTF-8 convertation