Move core codes to subdirectory
Fix encoding bug; Add functions to template;
Fix encoding bug; Add functions to template;