Some code cleanup
Code cleanup and charset setting