change file structure and interfaces ,fix some bugs