fixed some bugs and comments