Bug fixes

Fixed some bugs.