fixed some bugs and found some bugs.