Add multi-byte support

Add multi-byte char support and fix misc.