fix some bugs and add notification function.
fix bugs and add notification function