Change Config file

Change the configuration file to xml file. Refine code and fix some bugs