Fixed some bugs