fix some bugs. add a configuration class.