Bug fix

Fixed some bugs.