Fixed a few bugs

Fixed a few bugs