fixing some bugs.