fix bugs

fix some bugs.
delete unused code