fix bugs and add features

fix bugs and add features