Bug fixes

fixed some bugs.